RoadRunner Reference Manual | |||
---|---|---|---|
<<< Previous Page | Home | Up | Next Page >>> |
struct RRWorkPool; struct RRWorkPoolClass; #define RRWPGROUP (x) typedef RRWPGroup; RRWorkPool* rr_work_pool_new (gint max_threads); void rr_work_pool_free (RRWorkPool *pool); void rr_work_pool_push (RRWorkPool *pool, RRWPGroup gid, GFunc func, gpointer data, gpointer user_data); void rr_work_pool_join (RRWorkPool *pool, RRWPGroup gid); |
struct RRWorkPool { gint max_threads; gint num_threads; GSList *work; GSList *active; GMutex *mutex; GCond *add_cond; GCond *remove_cond; gboolean shutdown; }; |
RRWorkPool* rr_work_pool_new (gint max_threads); |
Create a new work pool. The RRWorkPool works like an ordinary thread pool with the exception that each "work item" is assigned a gid (group id). But the work pool guarantees that two items with the same gid value cant be executed in parallel.
max_threads : | The maximum number of threads this pool should use. |
Returns : | a newly allocated RRWorkPool. |
void rr_work_pool_free (RRWorkPool *pool); |
Waits until all work items have been executed then all resourced used by the work pool are returned to the operating system.
pool : | A RRWorkPool. |
void rr_work_pool_push (RRWorkPool *pool, RRWPGroup gid, GFunc func, gpointer data, gpointer user_data); |
Inserts func to the list of task to be executed by the pool. The work pool guarantees that two or more tasks with the same gid will never be executed in parallel.
pool : | |
gid : | a thread group id. |
func : | a function to execute by one thread in the work pool. |
data : | first argument to func |
user_data : | second argument to func |
void rr_work_pool_join (RRWorkPool *pool, RRWPGroup gid); |
blocks until all tasks of the given gid are executed.
pool : | a RRWork pool. |
gid : | a thread group id |