Concord - C Discord API library
A Discord API wrapper library written in C
threadpool.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016, Mathias Brossard <mathias@brossard.org>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef _THREADPOOL_H_
30#define _THREADPOOL_H_
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
45#define MAX_THREADS 64
46#define MAX_QUEUE 65536
47
49
50typedef enum {
57
58typedef enum {
61
70threadpool_t *threadpool_create(int thread_count, int queue_size, int flags);
71
82int threadpool_add(threadpool_t *pool, void (*routine)(void *),
83 void *arg, int flags);
84
95int threadpool_destroy(threadpool_t *pool, int flags);
96
97#ifdef __cplusplus
98}
99#endif
100
101#endif /* _THREADPOOL_H_ */
threadpool_destroy_flags_t
Definition: threadpool.h:58
@ threadpool_graceful
Definition: threadpool.h:59
int threadpool_add(threadpool_t *pool, void(*routine)(void *), void *arg, int flags)
add a new task in the queue of a thread pool
int threadpool_destroy(threadpool_t *pool, int flags)
Stops and destroys a thread pool.
threadpool_t * threadpool_create(int thread_count, int queue_size, int flags)
Creates a threadpool_t object.
struct threadpool_t threadpool_t
Definition: threadpool.h:48
threadpool_error_t
Definition: threadpool.h:50
@ threadpool_invalid
Definition: threadpool.h:51
@ threadpool_thread_failure
Definition: threadpool.h:55
@ threadpool_lock_failure
Definition: threadpool.h:52
@ threadpool_shutdown
Definition: threadpool.h:54
@ threadpool_queue_full
Definition: threadpool.h:53