Main Page | Modules | Data Structures | File List | Data Fields

Thread Pools
[State Daemon]


Typedefs

typedef smd_threadpool_t smd_threadpool_t
typedef sul_error_t *(* smd_threadpool_fn_t )(void *baton, apr_pool_t *pool)

Functions

sul_error_tsmd_threadpool_create (smd_threadpool_t **threadp, apr_size_t quesz, apr_size_t numthrds, smd_threadpool_fn_t fn, apr_pool_t *pool)
sul_error_tsmd_threadpool_spawn (smd_threadpool_t *threadp, apr_pool_t *pool)
sul_error_tsmd_threadpool_push (smd_threadpool_t *threadp, void *arg)
sul_boolean_t smd_threadpool_running (smd_threadpool_t *threadp)
sul_error_tsmd_threadpool_destroy (smd_threadpool_t *threadp)

Typedef Documentation

typedef sul_error_t*(* smd_threadpool_fn_t)(void *baton, apr_pool_t *pool)
 

Each therad pool as a work function that is invoked by child threads to handle incoming packages of data. This package of data can determine the type of work to do, for example. A work function will only be invoked once per package of data.

typedef struct smd_threadpool_t smd_threadpool_t
 

Thread pool structure that stores information on a group of Threads that are cooporating to process incoming packages of data.


Function Documentation

sul_error_t* smd_threadpool_create smd_threadpool_t **  threadp,
apr_size_t  quesz,
apr_size_t  numthrds,
smd_threadpool_fn_t  fn,
apr_pool_t *  pool
 

Create a new Thread Pool in THREADP, creating NUMTHRDS threads that are ready and willing to retrieve and server packages given to this thread pool.

Parameters:
threadp A pointer to receive the new Thread Pool.
quesz Size of the queue to create.
numthrds Number of threads to create in the pool.
fn Worker function for handling packages given to the threads.
pool Pool to allocate the Thread Pool from.
Returns:
An sul_error_t instance if an error occured and NULL otherwise.

sul_error_t* smd_threadpool_destroy smd_threadpool_t threadp  ) 
 

Destroys a thread pool, cleaning up all of the active Threads.

Parameters:
threadp A Thread Pool.
Returns:
An sul_error_t instance if an error occured and NULL otherwise.

sul_error_t* smd_threadpool_push smd_threadpool_t threadp,
void *  arg
 

Pushes a new package of data into the thread pool's queue. Immediately after this if a thread is waiting then the package will be poped off and handled in the worker function. This function returns immediately.

Parameters:
threadp A Thread Pool.
arg Package of data.
Returns:
An sul_error_t instance if an error occured and NULL otherwise.

sul_boolean_t smd_threadpool_running smd_threadpool_t threadp  ) 
 

Checks to see if the given thread pool is still running or if its been terminated and dead.

Parameters:
threadp A Thread Pool.
Returns:
A flag indicating if this Thread Pool is done.

sul_error_t* smd_threadpool_spawn smd_threadpool_t threadp,
apr_pool_t *  pool
 

Spawns a new worker thread in this Thread Pool.

Parameters:
threadp A Thread Pool.
pool Pool to allocate the new Thread from.
Returns:
An sul_error_t instance if an error occured and NULL otherwise.


Generated on Wed Apr 28 09:38:38 2004 for State by doxygen 1.3.5