- began to clean code documentation
[strongswan.git] / Source / charon / threads / 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 typedef struct thread_pool_t thread_pool_t;
32
33 /**
34 * @brief A thread_pool contains a pool of threads processing 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 struct thread_pool_t {
40 /**
41 * @brief return currently instanciated threads
42 *
43 * @param thread_pool thread_pool_t object
44 * @return size of thread pool
45 */
46 size_t (*get_pool_size) (thread_pool_t *thread_pool);
47 /**
48 * @brief destroy pool
49 *
50 * sends cancellation request to all threads and AWAITS their termination.
51 *
52 * @param thread_pool thread_pool_t object
53 * @return
54 * - SUCCESS in any case
55 */
56 status_t (*destroy) (thread_pool_t *thread_pool);
57 };
58
59 /**
60 * @brief Create the thread pool using using pool_size of threads
61 *
62 * @param pool_size desired pool size
63 * @return
64 * - NULL if no threads could be created
65 * - thread_pool if one ore more threads could be instanciated
66 */
67 thread_pool_t *thread_pool_create(size_t pool_size);
68
69
70 #endif /*THREAD_POOL_H_*/