Flint2-0.1.0.5: Haskell bindings for the flint library for number theory
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Number.Flint.ThreadPool

Description

 
Synopsis

Thread pool

Thread pool functions

thread_pool_init :: Ptr CThreadPool -> CLong -> IO () Source #

thread_pool_init T size

Initialise T and create size sleeping threads that are available to work. If size \le 0 no threads are created and future calls to thread_pool_request will return \(0\) (unless thread_pool_set_size has been called).

thread_pool_get_size :: Ptr CThreadPool -> IO CLong Source #

thread_pool_get_size T

Return the number of threads in T.

thread_pool_set_size :: Ptr CThreadPool -> CLong -> IO CInt Source #

thread_pool_set_size T new_size

If all threads in T are in the available state, resize T and return 1. Otherwise, return 0.

thread_pool_request :: Ptr CThreadPool -> Ptr CThreadPoolHandle -> CLong -> IO CLong Source #

thread_pool_request T out requested

Put at most requested threads in the unavailable state and return their handles. The handles are written to out and the number of handles written is returned. These threads must be released by a call to thread_pool_give_back.

thread_pool_wake :: Ptr CThreadPool -> Ptr CThreadPoolHandle -> CInt -> FunPtr (Ptr () -> IO ()) -> Ptr () -> IO () Source #

thread_pool_wake T i max_workers f a

Wake up a sleeping thread i and have it work on f(a). The thread being woken will be allowed to start max_workers additional worker threads. Usually this value should be set to 0.

thread_pool_wait :: Ptr CThreadPool -> Ptr CThreadPoolHandle -> IO () Source #

thread_pool_wait T i

Wait for thread i to finish working and go back to sleep.

thread_pool_give_back :: Ptr CThreadPool -> Ptr CThreadPoolHandle -> IO () Source #

thread_pool_give_back T i

Put thread i back in the available state. This thread should be sleeping when this function is called.

thread_pool_clear :: Ptr CThreadPool -> IO () Source #

thread_pool_clear T

Release any resources used by T. All threads should be given back before this function is called.