C4 Engine
C4 Engine API Documentation

class BatchJob

Defined in:  C4Threads.h
The BatchJob class represents a single job that can be part of a batch.

class BatchJob : public Job, public ListElement<BatchJob>


BatchJob(ExecuteCallback *execCallback, void *cookie = nullptruint32 flags = 0);

BatchJob(ExecuteCallback *execCallback, FinalizeCallback *finalCallback, void *cookie = nullptruint32 flags = 0);

execCallback The main execution function for the job.
finalCallback The finalization function for the job.
cookie A pointer to user-defined data that is passed to the job's execution function.
flags The job flags. See below for possible values.
The BatchJob class is used to encapsulate the execution function and data for a single job. Batch jobs are queued for execution by one of the Thread Manager's worker threads by calling the ThreadMgr::SubmitJob function and specifying a Batch object.

The functions specified by the execCallback and finalCallback parameters should have the following signatures.

typedef void ExecuteCallback(Job *, void *);

typedef void FinalizeCallback(Job *, void *);

The first parameter passed to the execution function is a pointer to the Job object itself, and the second parameter is the cookie parameter that was passed to the Job constructor.

The flags parameter can be a combination (through logical OR) of the following constants.
kJobNonpersistent The job is nonpersistent. If this flag is set, then the job is automatically destroyed when its batch is finished.
If the kJobNonpersistent flag is specified, then the BatchJob object is automatically destroyed by the ThreadMgr::FinishBatch function after a batch has finished executing.
Base Classes
Job A batch job is a specialized type of job.
ListElement<BatchJob> Used internally by the Thread Manager.
See Also