chunk_to_hex() function declaration deleted
[strongswan.git] / src / charon / threads / thread_pool.h
1 /**
2 * @file thread_pool.h
3 *
4 * @brief Interface of thread_pool_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005-2006 Martin Willi
10 * Copyright (C) 2005 Jan Hutter
11 * Hochschule fuer Technik Rapperswil
12 *
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>.
17 *
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
21 * for more details.
22 */
23
24 #ifndef THREAD_POOL_H_
25 #define THREAD_POOL_H_
26
27 #include <stdlib.h>
28
29 #include <types.h>
30
31
32 typedef struct thread_pool_t thread_pool_t;
33
34 /**
35 * @brief A thread_pool consists of a pool of threads processing jobs from the job queue.
36 *
37 * Current implementation uses as many threads as specified in constructor.
38 * A more improved version would dynamically increase thread count if necessary.
39 *
40 * @b Constructors:
41 * - thread_pool_create()
42 *
43 * @todo Add support for dynamic thread handling
44 *
45 * @ingroup threads
46 */
47 struct thread_pool_t {
48
49 /**
50 * @brief Return currently instanciated thread count.
51 *
52 * @param thread_pool calling object
53 * @return size of thread pool
54 */
55 u_int (*get_pool_size) (thread_pool_t *thread_pool);
56
57 /**
58 * @brief Get the number of threads currently waiting for work.
59 *
60 * @param thread_pool calling object
61 * @return number of idle threads
62 */
63 u_int (*get_idle_threads) (thread_pool_t *thread_pool);
64
65 /**
66 * @brief Destroy a thread_pool_t object.
67 *
68 * Sends cancellation request to all threads and AWAITS their termination.
69 *
70 * @param thread_pool calling object
71 */
72 void (*destroy) (thread_pool_t *thread_pool);
73 };
74
75 /**
76 * @brief Create the thread pool using using pool_size of threads.
77 *
78 * @param pool_size desired pool size
79 * @return
80 * - thread_pool_t object if one ore more threads could be started, or
81 * - NULL if no threads could be created
82 *
83 * @ingroup threads
84 */
85 thread_pool_t *thread_pool_create(size_t pool_size);
86
87
88 #endif /*THREAD_POOL_H_*/