thrGetWorkforce

Return a pointer to a singleton workforce

Description:

Applications that may be run in a monolith environment such as ICL or ORAC-DR should normally use this function in preference to thrCreateWorkforce. Use of this function reduces the total number of threads that are started and killed within a monolith, thus reducing the associated overheads of CPU time and memory.

One the first invocation, this function invokes thrCreateWorkforce to create a new workforce with the requested number of threads. A pointer to this workforce is stored internally, and the same pointer is returned on each subsequent invocation of this function.

If the returned workforce is freed explicitly using thrDestroyWorkforce, then the next invocation of this function will create a new workforce again. For this reason, applications should not normally free the returned workforce explicitly. The resources associated with the workforce will be freed when the monolith process terminates.

Invocation

ThrWorkForce thrGetWorkforce( int nworker, int status )

Arguments

nworker
If this value is negative, a NULL pointer is returned if no workforce exists on entry, and a pointer to the existing workforce is returned otherwise. If " nworker" is zero, a NULL pointer is always returned (in which case the app should be run in a single thread without any workers). If " nworker" is positive, it will be ignored if a workforce already exists, and will be used to specify the number of worker threads in the new workforce otherwise.
status
Pointer to the inherited status value.

Returned Value

A pointer to a workforce. The returned pointer should not usually be
freed explicitly (e.g. with thrDestroyWorkforce).