eyBuildLib API Reference : eyBuildLib
ebthreadpool - a flexible thread pool library
ebThreadPoolCreate( ) - create a static thread pool
ebThreadPoolJobAdd( ) - add a job into thread pool
ebThreadPoolDestroy( ) - destroy thread pool
ebThreadPoolGetRequests( ) - gets the request in queue of thread pool
ebThreadPoolActiveThreads( ) - gets the number of Active threads in thread pool
This library support Win32, POSIX OS and VxWorks.
ebthreadpool.h ebthread.h
ebThreadPoolCreate( ) - create a static thread pool
EBTHREAD_POOL * ebThreadPoolCreate ( EBTHREAD_ATTR * pattr, /* thread attribute */ size_t threads_num, /* threads number in thread pool */ size_t queue_len /* length of request queue */ )
This routine is to create a static thread pool, which has threads_num work threads. Before call ebThreadPoolJobAdd( ) all work threads are waiting a ready queue.
OK, ERROR if no enough resource in system.
ebThreadPoolJobAdd( ) - add a job into thread pool
int ebThreadPoolJobAdd ( EBTHREAD_POOL * pool, /* thread pool ID */ unsigned long timeout, /* wait microseconds if queue empty */ EBCALLBACK callback, /* job callback routine */ void * arg1, void * arg2, void * arg3, void * arg4, void * arg5 )
This routine adds a new job into thread pool. It will be blocked at most timeout millisecond if the wait queue is full. When there has free thread, it will pick up the first request in the wait queue and execute the callback.
OK, ERROR or EBTIMEOUT
ebThreadPoolDestroy( ) - destroy thread pool
int ebThreadPoolDestroy ( EBTHREAD_POOL * pool )
This routine destroy thread pool and release all resource. It first try to informs all work thread exit; After all work threads exit, it frees the all resources in thread pool. Note, user should stop call ebThreadPoolJobAdd( ) when call this routine in multi-threads invironment.
OK/ERROR
ebThreadPoolGetRequests( ) - gets the request in queue of thread pool
int ebThreadPoolGetRequests ( EBTHREAD_POOL * pool )
This routine get the request in queue of thread pool.
numuber of requests in queue, or ERROR
ebThreadPoolActiveThreads( ) - gets the number of Active threads in thread pool
int ebThreadPoolActiveThreads ( EBTHREAD_POOL * pool )
This routine gets the number of Active threads in thread pool.
numuber of idle threads, or ERROR