mirror of
https://github.com/MariaDB/server.git
synced 2025-01-22 14:54:20 +01:00
ce6b171044
{{{ svn merge -r 5899:5987 https://svn.tokutek.com/tokudb/tokudb }}} and resolve the conflicts. git-svn-id: file:///svn/tokudb.1131b@5988 c7de825b-a66e-492c-adef-691d508d4ae1
46 lines
1.8 KiB
C
46 lines
1.8 KiB
C
// A threadpool is a limited set of threads that can be used to apply a
|
|
// function to work contained in a work queue. The work queue is outside
|
|
// of the scope of the threadpool; the threadpool merely provides
|
|
// mechanisms to grow the number of threads in the threadpool on demand.
|
|
|
|
typedef struct threadpool *THREADPOOL;
|
|
|
|
// Create a new threadpool
|
|
// Effects: a new threadpool is allocated and initialized. the number of
|
|
// threads in the threadpool is limited to max_threads. initially, there
|
|
// are no threads in the pool.
|
|
// Returns: if there are no errors, the threadpool is set and zero is returned.
|
|
// Otherwise, an error number is returned.
|
|
|
|
int threadpool_create(THREADPOOL *threadpoolptr, int max_threads);
|
|
|
|
// Destroy a threadpool
|
|
// Effects: the calling thread joins with all of the threads in the threadpool.
|
|
// Effects: the threadpool memory is freed.
|
|
// Returns: the threadpool is set to null.
|
|
|
|
void threadpool_destroy(THREADPOOL *threadpoolptr);
|
|
|
|
// Maybe add a thread to the threadpool.
|
|
// Effects: the number of threads in the threadpool is expanded by 1 as long
|
|
// as the current number of threads in the threadpool is less than the max
|
|
// and there are no idle threads.
|
|
// Effects: if the thread is create, it calls the function f with argument arg
|
|
// Expects: external serialization on this function; only one thread may
|
|
// execute this function
|
|
|
|
void threadpool_maybe_add(THREADPOOL theadpool, void *(*f)(void *), void *arg);
|
|
|
|
// Set the current thread busy
|
|
// Effects: the threadpool keeps a count of the number of idle threads. It
|
|
// uses this count to control the creation of additional threads.
|
|
|
|
void threadpool_set_thread_busy(THREADPOOL);
|
|
|
|
// Set the current thread idle
|
|
|
|
void threadpool_set_thread_idle(THREADPOOL);
|
|
|
|
// get the current number of threads
|
|
|
|
int threadpool_get_current_threads(THREADPOOL);
|