moved interface enumeration code to socket, where it belongs
[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 * @brief Return currently instanciated thread count.
50 *
51 * @param thread_pool calling object
52 * @return size of thread pool
53 */
54 size_t (*get_pool_size) (thread_pool_t *thread_pool);
55
56 /**
57 * @brief Destroy a thread_pool_t object.
58 *
59 * Sends cancellation request to all threads and AWAITS their termination.
60 *
61 * @param thread_pool calling object
62 */
63 void (*destroy) (thread_pool_t *thread_pool);
64 };
65
66 /**
67 * @brief Create the thread pool using using pool_size of threads.
68 *
69 * @param pool_size desired pool size
70 * @return
71 * - thread_pool_t object if one ore more threads could be started, or
72 * - NULL if no threads could be created
73 *
74 * @ingroup threads
75 */
76 thread_pool_t *thread_pool_create(size_t pool_size);
77
78
79 #endif /*THREAD_POOL_H_*/