4 * @brief Thread-pool with some threads processing the job_queue
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 #ifndef THREAD_POOL_H_
24 #define THREAD_POOL_H_
31 * @brief A thread_pool contains a pool of threads processing the job queue
33 * Current implementation uses as many threads as specified in constructor.
34 * A more improved version would dynamically increase thread count if necessary...
36 typedef struct thread_pool_s thread_pool_t
;
38 struct thread_pool_s
{
40 * @brief return currently active threads
42 * @param thread_pool thread_pool_t object
43 * @param size [out] actual size of pool
44 * @return SUCCESS Thread flagged for termination
46 status_t (*get_pool_size
) (thread_pool_t
*thread_pool
, size_t *pool_size
);
50 * sends cancellation request to all threads and AWAITS their termination.
52 * @param thread_pool thread_pool_t object
55 status_t (*destroy
) (thread_pool_t
*thread_pool
);
59 * @brief Create the thread pool using using pool_size of threads
61 * @param pool_size desired pool size
62 * @return NULL when no thread could be created
63 * thread_pool when one ore more threads could be created
65 thread_pool_t
*thread_pool_create(size_t pool_size
);
68 #endif /*THREAD_POOL_H_*/