4 * @brief Interface of thread_pool_t.
9 * Copyright (C) 2005-2006 Martin Willi
10 * Copyright (C) 2005 Jan Hutter
11 * Hochschule fuer Technik Rapperswil
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 #ifndef THREAD_POOL_H_
25 #define THREAD_POOL_H_
27 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
{
49 * @brief Return currently instanciated thread count.
51 * @param thread_pool calling object
52 * @return size of thread pool
54 u_int (*get_pool_size
) (thread_pool_t
*thread_pool
);
57 * @brief Get the number of threads currently waiting for work.
59 * @param thread_pool calling object
60 * @return number of idle threads
62 u_int (*get_idle_threads
) (thread_pool_t
*thread_pool
);
65 * @brief Destroy a thread_pool_t object.
67 * Sends cancellation request to all threads and AWAITS their termination.
69 * @param thread_pool calling object
71 void (*destroy
) (thread_pool_t
*thread_pool
);
75 * @brief Create the thread pool using using pool_size of threads.
77 * @param pool_size desired pool size
79 * - thread_pool_t object if one ore more threads could be started, or
80 * - NULL if no threads could be created
84 thread_pool_t
*thread_pool_create(size_t pool_size
);
87 #endif /*THREAD_POOL_H_*/