- updated comments
[strongswan.git] / Source / charon / thread_pool.h
1 /**
2 * @file thread_pool.h
3 *
4 * @brief Thread pool with some threads processing the job_queue
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 * @brief A thread_pool contains a pool of threads processing the job queue.
32 *
33 * Current implementation uses as many threads as specified in constructor.
34 * A more improved version would dynamically increase thread count if necessary...
35 */
36 typedef struct thread_pool_s thread_pool_t;
37
38 struct thread_pool_s {
39 /**
40 * @brief return currently instanciated threads
41 *
42 * @param thread_pool thread_pool_t object
43 * @return size of thread pool
44 */
45 size_t (*get_pool_size) (thread_pool_t *thread_pool);
46 /**
47 * @brief destroy pool
48 *
49 * sends cancellation request to all threads and AWAITS their termination.
50 *
51 * @param thread_pool thread_pool_t object
52 * @return
53 * - SUCCESS in any case
54 */
55 status_t (*destroy) (thread_pool_t *thread_pool);
56 };
57
58 /**
59 * @brief Create the thread pool using using pool_size of threads
60 *
61 * @param pool_size desired pool size
62 * @return
63 * - NULL if no threads could be created
64 * - thread_pool if one ore more threads could be instanciated
65 */
66 thread_pool_t *thread_pool_create(size_t pool_size);
67
68
69 #endif /*THREAD_POOL_H_*/