4 * @brief Interface of thread_pool_t.
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 typedef struct thread_pool_t thread_pool_t
;
34 * @brief A thread_pool consists of a pool of threads processing jobs from the job queue.
36 * Current implementation uses as many threads as specified in constructor.
37 * A more improved version would dynamically increase thread count if necessary.
40 * - thread_pool_create()
42 * @todo Add support for dynamic thread handling
46 struct thread_pool_t
{
48 * @brief Return currently instanciated thread count.
50 * @param thread_pool calling object
51 * @return size of thread pool
53 size_t (*get_pool_size
) (thread_pool_t
*thread_pool
);
56 * @brief Destroy a thread_pool_t object.
58 * Sends cancellation request to all threads and AWAITS their termination.
60 * @param thread_pool calling object
62 void (*destroy
) (thread_pool_t
*thread_pool
);
66 * @brief Create the thread pool using using pool_size of threads.
68 * @param pool_size desired pool size
70 * - thread_pool_t object if one ore more threads could be started, or
71 * - NULL if no threads could be created
75 thread_pool_t
*thread_pool_create(size_t pool_size
);
78 #endif /*THREAD_POOL_H_*/