Concord - C Discord API library
A Discord API wrapper library written in C
|
Threadpool Header File. More...
Go to the source code of this file.
Macros | |
#define | MAX_THREADS 64 |
#define | MAX_QUEUE 65536 |
Typedefs | |
typedef struct threadpool_t | threadpool_t |
Enumerations | |
enum | threadpool_error_t { threadpool_invalid = -1 , threadpool_lock_failure = -2 , threadpool_queue_full = -3 , threadpool_shutdown = -4 , threadpool_thread_failure = -5 } |
enum | threadpool_destroy_flags_t { threadpool_graceful = 1 } |
Functions | |
threadpool_t * | threadpool_create (int thread_count, int queue_size, int flags) |
Creates a threadpool_t object. More... | |
int | threadpool_add (threadpool_t *pool, void(*routine)(void *), void *arg, int flags) |
add a new task in the queue of a thread pool More... | |
int | threadpool_destroy (threadpool_t *pool, int flags) |
Stops and destroys a thread pool. More... | |
Threadpool Header File.
#define MAX_THREADS 64 |
Increase this constants at your own risk Large values might slow down your system
#define MAX_QUEUE 65536 |
typedef struct threadpool_t threadpool_t |
enum threadpool_error_t |
threadpool_t * threadpool_create | ( | int | thread_count, |
int | queue_size, | ||
int | flags | ||
) |
Creates a threadpool_t object.
@function threadpool_create
thread_count | Number of worker threads. |
queue_size | Size of the queue. |
flags | Unused parameter. |
int threadpool_add | ( | threadpool_t * | pool, |
void(*)(void *) | routine, | ||
void * | arg, | ||
int | flags | ||
) |
add a new task in the queue of a thread pool
@function threadpool_add
pool | Thread pool to which add the task. |
function | Pointer to the function that will perform the task. |
argument | Argument to be passed to the function. |
flags | Unused parameter. |
int threadpool_destroy | ( | threadpool_t * | pool, |
int | flags | ||
) |
Stops and destroys a thread pool.
@function threadpool_destroy
pool | Thread pool to destroy. |
flags | Flags for shutdown |
Known values for flags are 0 (default) and threadpool_graceful in which case the thread pool doesn't accept any new tasks but processes all pending tasks before shutdown.