Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef prtpool_h___ |
michael@0 | 7 | #define prtpool_h___ |
michael@0 | 8 | |
michael@0 | 9 | #include "prtypes.h" |
michael@0 | 10 | #include "prthread.h" |
michael@0 | 11 | #include "prio.h" |
michael@0 | 12 | #include "prerror.h" |
michael@0 | 13 | |
michael@0 | 14 | /* |
michael@0 | 15 | * NOTE: |
michael@0 | 16 | * THIS API IS A PRELIMINARY VERSION IN NSPR 4.0 AND IS SUBJECT TO |
michael@0 | 17 | * CHANGE |
michael@0 | 18 | */ |
michael@0 | 19 | |
michael@0 | 20 | PR_BEGIN_EXTERN_C |
michael@0 | 21 | |
michael@0 | 22 | typedef struct PRJobIoDesc { |
michael@0 | 23 | PRFileDesc *socket; |
michael@0 | 24 | PRErrorCode error; |
michael@0 | 25 | PRIntervalTime timeout; |
michael@0 | 26 | } PRJobIoDesc; |
michael@0 | 27 | |
michael@0 | 28 | typedef struct PRThreadPool PRThreadPool; |
michael@0 | 29 | typedef struct PRJob PRJob; |
michael@0 | 30 | typedef void (PR_CALLBACK *PRJobFn) (void *arg); |
michael@0 | 31 | |
michael@0 | 32 | /* Create thread pool */ |
michael@0 | 33 | NSPR_API(PRThreadPool *) |
michael@0 | 34 | PR_CreateThreadPool(PRInt32 initial_threads, PRInt32 max_threads, |
michael@0 | 35 | PRUint32 stacksize); |
michael@0 | 36 | |
michael@0 | 37 | /* queue a job */ |
michael@0 | 38 | NSPR_API(PRJob *) |
michael@0 | 39 | PR_QueueJob(PRThreadPool *tpool, PRJobFn fn, void *arg, PRBool joinable); |
michael@0 | 40 | |
michael@0 | 41 | /* queue a job, when a socket is readable */ |
michael@0 | 42 | NSPR_API(PRJob *) |
michael@0 | 43 | PR_QueueJob_Read(PRThreadPool *tpool, PRJobIoDesc *iod, |
michael@0 | 44 | PRJobFn fn, void * arg, PRBool joinable); |
michael@0 | 45 | |
michael@0 | 46 | /* queue a job, when a socket is writeable */ |
michael@0 | 47 | NSPR_API(PRJob *) |
michael@0 | 48 | PR_QueueJob_Write(PRThreadPool *tpool, PRJobIoDesc *iod, |
michael@0 | 49 | PRJobFn fn, void * arg, PRBool joinable); |
michael@0 | 50 | |
michael@0 | 51 | /* queue a job, when a socket has a pending connection */ |
michael@0 | 52 | NSPR_API(PRJob *) |
michael@0 | 53 | PR_QueueJob_Accept(PRThreadPool *tpool, PRJobIoDesc *iod, |
michael@0 | 54 | PRJobFn fn, void * arg, PRBool joinable); |
michael@0 | 55 | |
michael@0 | 56 | /* queue a job, when the socket connection to addr succeeds or fails */ |
michael@0 | 57 | NSPR_API(PRJob *) |
michael@0 | 58 | PR_QueueJob_Connect(PRThreadPool *tpool, PRJobIoDesc *iod, |
michael@0 | 59 | const PRNetAddr *addr, PRJobFn fn, void * arg, PRBool joinable); |
michael@0 | 60 | |
michael@0 | 61 | /* queue a job, when a timer exipres */ |
michael@0 | 62 | NSPR_API(PRJob *) |
michael@0 | 63 | PR_QueueJob_Timer(PRThreadPool *tpool, PRIntervalTime timeout, |
michael@0 | 64 | PRJobFn fn, void * arg, PRBool joinable); |
michael@0 | 65 | /* cancel a job */ |
michael@0 | 66 | NSPR_API(PRStatus) |
michael@0 | 67 | PR_CancelJob(PRJob *job); |
michael@0 | 68 | |
michael@0 | 69 | /* join a job */ |
michael@0 | 70 | NSPR_API(PRStatus) |
michael@0 | 71 | PR_JoinJob(PRJob *job); |
michael@0 | 72 | |
michael@0 | 73 | /* shutdown pool */ |
michael@0 | 74 | NSPR_API(PRStatus) |
michael@0 | 75 | PR_ShutdownThreadPool(PRThreadPool *tpool); |
michael@0 | 76 | |
michael@0 | 77 | /* join pool, wait for exit of all threads */ |
michael@0 | 78 | NSPR_API(PRStatus) |
michael@0 | 79 | PR_JoinThreadPool(PRThreadPool *tpool); |
michael@0 | 80 | |
michael@0 | 81 | PR_END_EXTERN_C |
michael@0 | 82 | |
michael@0 | 83 | #endif /* prtpool_h___ */ |