- fixed bad bugs in kernel interface
[strongswan.git] / Source / 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 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
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>.
16 *
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
20 * for more details.
21 */
22
23 #ifndef THREAD_POOL_H_
24 #define THREAD_POOL_H_
25
26 #include <stdlib.h>
27
28 #include <types.h>
29
30
31 typedef struct thread_pool_t thread_pool_t;
32
33 /**
34 * @brief A thread_pool consists of a pool of threads processing jobs from the job queue.
35 *
36 * Current implementation uses as many threads as specified in constructor.
37 * A more improved version would dynamically increase thread count if necessary.
38 *
39 * @b Constructors:
40 * - thread_pool_create()
41 *
42 * @todo Add support for dynamic thread handling
43 *
44 * @ingroup threads
45 */
46 struct thread_pool_t {
47 /**
48 * @brief Return currently instanciated thread count.
49 *
50 * @param thread_pool calling object
51 * @return size of thread pool
52 */
53 size_t (*get_pool_size) (thread_pool_t *thread_pool);
54
55 /**
56 * @brief Destroy a thread_pool_t object.
57 *
58 * Sends cancellation request to all threads and AWAITS their termination.
59 *
60 * @param thread_pool calling object
61 */
62 void (*destroy) (thread_pool_t *thread_pool);
63 };
64
65 /**
66 * @brief Create the thread pool using using pool_size of threads.
67 *
68 * @param pool_size desired pool size
69 * @return
70 * - thread_pool_t object if one ore more threads could be started, or
71 * - NULL if no threads could be created
72 *
73 * @ingroup threads
74 */
75 thread_pool_t *thread_pool_create(size_t pool_size);
76
77
78 #endif /*THREAD_POOL_H_*/