| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Data.Number.Flint.ThreadPool
Contents
Description
Synopsis
- data ThreadPool = ThreadPool !(ForeignPtr CThreadPool)
- type CThreadPool = CFlint ThreadPool
- data ThreadPoolHandle = ThreadPoolHandle !(ForeignPtr CThreadPoolHandle)
- type CThreadPoolHandle = CFlint ThreadPoolHandle
- thread_pool_init :: Ptr CThreadPool -> CLong -> IO ()
- thread_pool_get_size :: Ptr CThreadPool -> IO CLong
- thread_pool_set_size :: Ptr CThreadPool -> CLong -> IO CInt
- thread_pool_request :: Ptr CThreadPool -> Ptr CThreadPoolHandle -> CLong -> IO CLong
- thread_pool_wake :: Ptr CThreadPool -> Ptr CThreadPoolHandle -> CInt -> FunPtr (Ptr () -> IO ()) -> Ptr () -> IO ()
- thread_pool_wait :: Ptr CThreadPool -> Ptr CThreadPoolHandle -> IO ()
- thread_pool_give_back :: Ptr CThreadPool -> Ptr CThreadPoolHandle -> IO ()
- thread_pool_clear :: Ptr CThreadPool -> IO ()
Thread pool
data ThreadPool Source #
Constructors
| ThreadPool !(ForeignPtr CThreadPool) |
Instances
| Storable CThreadPool Source # | |
Defined in Data.Number.Flint.ThreadPool.FFI Methods sizeOf :: CThreadPool -> Int # alignment :: CThreadPool -> Int # peekElemOff :: Ptr CThreadPool -> Int -> IO CThreadPool # pokeElemOff :: Ptr CThreadPool -> Int -> CThreadPool -> IO () # peekByteOff :: Ptr b -> Int -> IO CThreadPool # pokeByteOff :: Ptr b -> Int -> CThreadPool -> IO () # peek :: Ptr CThreadPool -> IO CThreadPool # poke :: Ptr CThreadPool -> CThreadPool -> IO () # | |
type CThreadPool = CFlint ThreadPool Source #
data ThreadPoolHandle Source #
Constructors
| ThreadPoolHandle !(ForeignPtr CThreadPoolHandle) |
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.