andre@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ andre@0: /* This Source Code Form is subject to the terms of the Mozilla Public andre@0: * License, v. 2.0. If a copy of the MPL was not distributed with this andre@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ andre@0: andre@0: #ifndef prtpool_h___ andre@0: #define prtpool_h___ andre@0: andre@0: #include "prtypes.h" andre@0: #include "prthread.h" andre@0: #include "prio.h" andre@0: #include "prerror.h" andre@0: andre@0: /* andre@0: * NOTE: andre@0: * THIS API IS A PRELIMINARY VERSION IN NSPR 4.0 AND IS SUBJECT TO andre@0: * CHANGE andre@0: */ andre@0: andre@0: PR_BEGIN_EXTERN_C andre@0: andre@0: typedef struct PRJobIoDesc { andre@0: PRFileDesc *socket; andre@0: PRErrorCode error; andre@0: PRIntervalTime timeout; andre@0: } PRJobIoDesc; andre@0: andre@0: typedef struct PRThreadPool PRThreadPool; andre@0: typedef struct PRJob PRJob; andre@0: typedef void (PR_CALLBACK *PRJobFn) (void *arg); andre@0: andre@0: /* Create thread pool */ andre@0: NSPR_API(PRThreadPool *) andre@0: PR_CreateThreadPool(PRInt32 initial_threads, PRInt32 max_threads, andre@0: PRUint32 stacksize); andre@0: andre@0: /* queue a job */ andre@0: NSPR_API(PRJob *) andre@0: PR_QueueJob(PRThreadPool *tpool, PRJobFn fn, void *arg, PRBool joinable); andre@0: andre@0: /* queue a job, when a socket is readable */ andre@0: NSPR_API(PRJob *) andre@0: PR_QueueJob_Read(PRThreadPool *tpool, PRJobIoDesc *iod, andre@0: PRJobFn fn, void * arg, PRBool joinable); andre@0: andre@0: /* queue a job, when a socket is writeable */ andre@0: NSPR_API(PRJob *) andre@0: PR_QueueJob_Write(PRThreadPool *tpool, PRJobIoDesc *iod, andre@0: PRJobFn fn, void * arg, PRBool joinable); andre@0: andre@0: /* queue a job, when a socket has a pending connection */ andre@0: NSPR_API(PRJob *) andre@0: PR_QueueJob_Accept(PRThreadPool *tpool, PRJobIoDesc *iod, andre@0: PRJobFn fn, void * arg, PRBool joinable); andre@0: andre@0: /* queue a job, when the socket connection to addr succeeds or fails */ andre@0: NSPR_API(PRJob *) andre@0: PR_QueueJob_Connect(PRThreadPool *tpool, PRJobIoDesc *iod, andre@0: const PRNetAddr *addr, PRJobFn fn, void * arg, PRBool joinable); andre@0: andre@0: /* queue a job, when a timer exipres */ andre@0: NSPR_API(PRJob *) andre@0: PR_QueueJob_Timer(PRThreadPool *tpool, PRIntervalTime timeout, andre@0: PRJobFn fn, void * arg, PRBool joinable); andre@0: /* cancel a job */ andre@0: NSPR_API(PRStatus) andre@0: PR_CancelJob(PRJob *job); andre@0: andre@0: /* join a job */ andre@0: NSPR_API(PRStatus) andre@0: PR_JoinJob(PRJob *job); andre@0: andre@0: /* shutdown pool */ andre@0: NSPR_API(PRStatus) andre@0: PR_ShutdownThreadPool(PRThreadPool *tpool); andre@0: andre@0: /* join pool, wait for exit of all threads */ andre@0: NSPR_API(PRStatus) andre@0: PR_JoinThreadPool(PRThreadPool *tpool); andre@0: andre@0: PR_END_EXTERN_C andre@0: andre@0: #endif /* prtpool_h___ */