|
NSPR Reference Previous Contents Next |
NOTE: This API is a preliminary version in NSPR 4.0 and is subject to change.
Thread pools create and manage threads to provide support for scheduling work (jobs) onto one or more threads. NSPR's thread pool is modeled on the thread pools described by David R. Butenhof in Programming with POSIX Threads (Addison-Wesley, 1997).
Thread Pool Types
Thread Pool Functions
PRJobIoDescPRJobFnPRThreadPoolPRJob
#include <prtpool.h>
typedef struct PRJobIoDesc {
PRFileDesc *socket;
PRErrorCode error;
PRIntervalTime timeout;
} PRJobIoDesc;
#include <prtpool.h>
typedev void (PR_CALLBACK *PRJobFn)(void *arg);
#include <prtpool.h>
#include <prtpool.h>
PR_CreateThreadPoolPR_QueueJobPR_QueueJob_ReadPR_QueueJob_WritePR_QueueJobAcceptPR_QueueJob_ConnectPR_QueueJob_TimerPR_CancelJobPR_JoinJobPR_ShutdownThreadPoolPR_JoinThreadPool
#include <prtpool.h>
NSPR_API(PRThreadPool *)
PR_CreateThreadPool(
PRInt32 initial_threads,
PRInt32 max_threads,
PRUint32 stacksize
);
PRThreadPool structure or NULL on error.
#include <prtpool.h>
NSPR_API(PRJob *)
PR_QueueJob(
PRThreadPool *tpool,
PRJobFn fn,
void *arg,
PRBool joinable
);
tpool |
A pointer to a PRThreadPool structure previously created
by a call to PR_CreateThreadPool.
|
fn |
The function to be executed when the job is executed.
|
arg |
A pointer to an argument passed to fn.
|
joinable |
If PR_TRUE, the job is joinable. If PR_FALSE, the job is not
joinable. See PR_JoinJob.
|
PRJob structure or NULL on error.
#include <prtpool.h>
NSPR_API(PRJob *)
PR_QueueJob_Read(
PRThreadPool *tpool,
PRJobIoDesc *iod,
PRJobFn fn,
void *arg,
PRBool joinable
);
tpool |
A pointer to a PRThreadPool structure previously created
by a call to PR_CreateThreadPool.
|
iod |
A pointer to a PRJobIoDesc structure
|
fn |
The function to be executed when the job is executed.
|
arg |
A pointer to an argument passed to fn.
|
joinable |
If PR_TRUE, the job is joinable. If PR_FALSE, the job is not
joinable. See PR_JoinJob.
|
PRJob structure or NULL on error.
#include <prtpool.h>
NSPR_API(PRJob *)
PR_QueueJob_Write(
PRThreadPool *tpool,
PRJobIoDesc *iod,
PRJobFn fn,
void * arg,
PRBool joinable
);
|
A pointer to a PRThreadPool structure previously created
by a call to PR_CreateThreadPool.
|
|
A pointer to a PRJobIoDesc structure
|
|
The function to be executed when the job is executed.
|
|
A pointer to an argument passed to fn.
|
|
If PR_TRUE, the job is joinable. If PR_FALSE, the job is not
joinable. See PR_JoinJob.
|
PRJob structure or NULL on error.
#include <prtpool.h>
NSPR_API(PRJob *)
PR_QueueJob_Accept(
PRThreadPool *tpool,
PRJobIoDesc *iod,
PRJobFn fn,
void * arg,
PRBool joinable
);
tpool |
A pointer to a PRThreadPool structure previously created
by a call to PR_CreateThreadPool.
|
iod |
A pointer to a PRJobIoDesc structure
|
fn |
The function to be executed when the job is executed.
|
arg |
A pointer to an argument passed to fn.
|
joinable |
If PR_TRUE, the job is joinable. If PR_FALSE, the job is not
joinable. See PR_JoinJob.
|
PRJob structure or NULL on error.
#include <prtpool.h>
NSPR_API(PRJob *)
PR_QueueJob_Connect(
PRThreadPool *tpool,
PRJobIoDesc *iod,
const PRNetAddr *addr,
PRJobFn fn,
void * arg,
PRBool joinable
);
|
A pointer to a PRThreadPool structure previously created
by a call to PR_CreateThreadPool.
|
|
A pointer to a PRJobIoDesc structure
|
|
Pointer to a PRNetAddr structure for the socket being
connected.
|
|
The function to be executed when the job is executed.
|
|
A pointer to an argument passed to fn.
|
|
If PR_TRUE, the job is joinable. If PR_FALSE, the job is not
joinable. See PR_JoinJob.
|
PRJob structure or NULL on error.
#include <prtpool.h>
NSPR_API(PRJob *)
PR_QueueJob_Timer(
PRThreadPool *tpool,
PRIntervalTime timeout,
PRJobFn fn,
void * arg,
PRBool joinable
);
tpool |
A pointer to a PRThreadPool structure previously created
by a call to PR_CreateThreadPool.
|
timeout |
A value, expressed as a PRIntervalTime, to wait before
queuing the job.
|
fn |
The function to be executed when the job is executed.
|
arg |
A pointer to an argument passed to fn.
|
joinable |
If PR_TRUE, the job is joinable. If PR_FALSE, the job is not
joinable. See PR_JoinJob.
|
PRJob structure or NULL on error.
#include <prtpool.h>
NSPR_API(PRStatus) PR_CancelJob(PRJob *job);
job |
A pointer to a PRJob structure returned by a PR_QueueJob
function representing the job to be cancelled.
|
PRStatus
#include <prtpool.h>
NSPR_API(PRStatus) PR_JoinJob(PRJob *job);
job |
A pointer to a PRJob structure returned by a PR_QueueJob
function representing the job to be cancelled.
|
PRStatus
#include <prtpool.h>
NSPR_API(PRStatus) PR_ShutdownThreadPool( PRThreadPool *tpool );
tpool |
A pointer to a PRThreadPool structure previously created
by a call to PR_CreateThreadPool.
|
PRStatus
#include <prtpool.h>
NSPR_API(PRStatus) PR_JoinThreadPool( PRThreadPool *tpool );
tpool |
A pointer to a PRThreadPool structure previously created
by a call to PR_CreateThreadPool.
|
PRStatus
Last Updated May 18, 2001