thrAddJob

Add a job to the list of jobs to be performed by a given workforce

Description:

This function adds a job to the list of jobs to be performed by the workforce. The job will start immediately if a worker thread is available to execute the job, and any jobs specified in the " wait_on" list have completed. Otherwise, it will start as soon as a worker thread becomes available and all the " wait_on" jobs have completed. Jobs are not necessarily started in the order in which they are added to the workforce.

Invocation

int thrAddJob( ThrWorkForce workforce, int flags, void data, void (func)( void , int ), int nwait_on, const int wait_on, int status )

Arguments

workforce
Pointer to the workforce. If NULL is supplied, the job is executed immediately in the current thread by calling " func" , and the " flags" and " checker" arguments are ignored.
flags
Flags controlling how the job behaves. See " Job Control Flags:" below.
data
An arbitrary data pointer that will be passed to the worker allocated to perform this job. If the THR__FREE_JOBDATA flag is set (see " flags" ) the pointer will be freed automatically by the function registered using thrFreeFun when the job completes.
func
A pointer to a function that the worker will invoke to do the job. This function takes two arguments; 1) the supplied " data" pointer, and 2) an inherited status pointer. It returns void.
nwait_on
The number of values supplied in the " wait_on" array. If zero, the " wait_on" pointer will be ignored.
wait_on
An array of integer identifiers for previously created jobs. The length of this array is given by " nwait_on" . No attempt will be made to start the new job until all the jobs specified in this array have completed. If NULL is supplied, or if " nwait_on" is zero, the new job will be started as soon as a worker thread becomes available.
status
Pointer to the inherited status value.

Returned Value

A positive integer identifier for the job. Zero if an error occurs.

Job Control Flags