1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
16 * THIS API IS A PRELIMINARY VERSION IN NSPR 4.0 AND IS SUBJECT TO
22 typedef struct PRJobIoDesc
{
25 PRIntervalTime timeout
;
28 typedef struct PRThreadPool PRThreadPool
;
29 typedef struct PRJob PRJob
;
30 typedef void (PR_CALLBACK
*PRJobFn
) (void *arg
);
32 /* Create thread pool */
33 NSPR_API(PRThreadPool
*)
34 PR_CreateThreadPool(PRInt32 initial_threads
, PRInt32 max_threads
,
39 PR_QueueJob(PRThreadPool
*tpool
, PRJobFn fn
, void *arg
, PRBool joinable
);
41 /* queue a job, when a socket is readable */
43 PR_QueueJob_Read(PRThreadPool
*tpool
, PRJobIoDesc
*iod
,
44 PRJobFn fn
, void * arg
, PRBool joinable
);
46 /* queue a job, when a socket is writeable */
48 PR_QueueJob_Write(PRThreadPool
*tpool
, PRJobIoDesc
*iod
,
49 PRJobFn fn
, void * arg
, PRBool joinable
);
51 /* queue a job, when a socket has a pending connection */
53 PR_QueueJob_Accept(PRThreadPool
*tpool
, PRJobIoDesc
*iod
,
54 PRJobFn fn
, void * arg
, PRBool joinable
);
56 /* queue a job, when the socket connection to addr succeeds or fails */
58 PR_QueueJob_Connect(PRThreadPool
*tpool
, PRJobIoDesc
*iod
,
59 const PRNetAddr
*addr
, PRJobFn fn
, void * arg
, PRBool joinable
);
61 /* queue a job, when a timer exipres */
63 PR_QueueJob_Timer(PRThreadPool
*tpool
, PRIntervalTime timeout
,
64 PRJobFn fn
, void * arg
, PRBool joinable
);
67 PR_CancelJob(PRJob
*job
);
71 PR_JoinJob(PRJob
*job
);
75 PR_ShutdownThreadPool(PRThreadPool
*tpool
);
77 /* join pool, wait for exit of all threads */
79 PR_JoinThreadPool(PRThreadPool
*tpool
);
83 #endif /* prtpool_h___ */