b2205fd176257ebca5e449f558f48eda04f92357
[strongswan.git] / Source / charon / thread_pool.h
1 /**
2 * @file worker.h
3 *
4 * @brief worker thread, gets jobs form 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 * A thread_pool contains a pool of threads processing the job queue
32 */
33 typedef struct thread_pool_s thread_pool_t;
34
35 struct thread_pool_s {
36 /**
37 * Stops process after processing current job
38 *
39 * @param thread_pool thread_pool_t object
40 * @param size [out] size of pool
41 * @return SUCCESS Thread flagged for termination
42 */
43 status_t (*get_pool_size) (thread_pool_t *thread_pool, size_t *pool_size);
44 /**
45 * Destroy pool, blocks until threads cleanly terminated
46 *
47 * @param thread_pool thread_pool_t object
48 * @return SUCCESS
49 */
50 status_t (*destroy) (thread_pool_t *thread_pool);
51 };
52
53 /**
54 * @brief Create the thread pool using using pool_size of threads
55 *
56 * @param pool_size desired pool size
57 * @return NULL when no thread could be created
58 * thread_pool when one ore more threads could be created
59 */
60 thread_pool_t *thread_pool_create(size_t pool_size);
61
62
63 #endif /*THREAD_POOL_H_*/