aboutsummaryrefslogtreecommitdiffstats
path: root/Source/charon/thread_pool.h
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2005-11-03 13:34:07 +0000
committerMartin Willi <martin@strongswan.org>2005-11-03 13:34:07 +0000
commitc93b51ec8cef6c0520b47902c9d034d0e9e859a4 (patch)
treeaf5a8a11e76fa93d7dddce6fa253910c81d180b5 /Source/charon/thread_pool.h
parentadca27eb76663402473a69fc3944919495f99fd6 (diff)
downloadstrongswan-c93b51ec8cef6c0520b47902c9d034d0e9e859a4.tar.bz2
strongswan-c93b51ec8cef6c0520b47902c9d034d0e9e859a4.tar.xz
""
Diffstat (limited to 'Source/charon/thread_pool.h')
-rw-r--r--Source/charon/thread_pool.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/Source/charon/thread_pool.h b/Source/charon/thread_pool.h
new file mode 100644
index 000000000..b2205fd17
--- /dev/null
+++ b/Source/charon/thread_pool.h
@@ -0,0 +1,63 @@
+/**
+ * @file worker.h
+ *
+ * @brief worker thread, gets jobs form job_queue
+ *
+ */
+
+/*
+ * Copyright (C) 2005 Jan Hutter, Martin Willi
+ * Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#ifndef THREAD_POOL_H_
+#define THREAD_POOL_H_
+
+#include <stdlib.h>
+
+#include "types.h"
+
+/**
+ * A thread_pool contains a pool of threads processing the job queue
+ */
+typedef struct thread_pool_s thread_pool_t;
+
+struct thread_pool_s {
+ /**
+ * Stops process after processing current job
+ *
+ * @param thread_pool thread_pool_t object
+ * @param size [out] size of pool
+ * @return SUCCESS Thread flagged for termination
+ */
+ status_t (*get_pool_size) (thread_pool_t *thread_pool, size_t *pool_size);
+ /**
+ * Destroy pool, blocks until threads cleanly terminated
+ *
+ * @param thread_pool thread_pool_t object
+ * @return SUCCESS
+ */
+ status_t (*destroy) (thread_pool_t *thread_pool);
+};
+
+/**
+ * @brief Create the thread pool using using pool_size of threads
+ *
+ * @param pool_size desired pool size
+ * @return NULL when no thread could be created
+ * thread_pool when one ore more threads could be created
+ */
+thread_pool_t *thread_pool_create(size_t pool_size);
+
+
+#endif /*THREAD_POOL_H_*/