StackThreads/MP: version 0.77 User's Guide
#include <st_foreign.h> @ void* stf_create_sync_worker_group(wgc, n, f, a0, a1, a2, a3) @ void stf_create_async_worker_group(wg, wgc, n, f, a0, a1, a2, a3) @ void* stf_wait_for_wg_to_exit(wg) @ int stf_did_wg_exit(wg) @ struct worker_group * wg; @ struct worker_group_conf * wgc; @ int n; @ void * (*f)(void *, void *, void *, void*); @ void * a0, * a1, * a2, * a3;
Both stf_create_sync_worker_group
and
stf_create_async_worker_group
create a group of workers that
initially consists of n workers. f specifies the entry function
and a0 ... a3 its arguments; the group as a whole performs
f(a0, a1, a2, a3)
, sharing threads created
directly or indirectly from f. wg is a pointer to an
uninitialized storage of type struct worker_group
.
Created workers exit when f returns, no matter whether there are
running threads that belong to the
group. stf_create_sync_worker_group
returns when workers exit. The
return value is the return value of f.
On the other hand, stf_create_async_worker_group
returns immediately.
stf_wait_for_wg_to_exit(wg)
waits for workers that belong to
wg to exit (by blocking the underlying worker) and returns the
return value of the entry function of wg. stf_did_wg_exit(wg)
returns 1 if workers that belong to wg have already exited and 0
otherwise.