C++ interface
The "Chunk" and "Task" base classes
In the C++ realization of the Chunks and Tasks model, the user defines chunk types and task types by creating new classes inheriting from the "Chunk" and "Task" base classes, as shown in the figure below.
Defining a chunk type
To define a new chunk type, the user creates a class inheriting from the cht::Chunk base class, for example like this:
The writeToBuffer() and assignFromBuffer() routines need to be provided so that the used Chunks and Tasks library (the runtime library) can serialize chunks if needed, e.g. to send chunks over the network if the program is run on a distributed memory cluster.
Defining a task type
To define a new task type, the user creates a class inheriting from the cht::Task base class, for example like this:
The work to be performed by the task is specified by implementing the execute() function, for example like this:
Inside the execute() function, new chunks may be registered using the registerChunk() function, as in the example above. The execute() function can also include registration of new tasks using the registerTask() function.