summaryrefslogtreecommitdiff
path: root/include/gras/thread_pool.hpp
diff options
context:
space:
mode:
authorJosh Blum2012-11-10 00:04:55 -0800
committerJosh Blum2012-11-10 00:04:55 -0800
commitbb756d67e039c1c8074e3da302786bf6759748a5 (patch)
tree607f381b74b05d2947b6311aba955c2f9d97a46d /include/gras/thread_pool.hpp
parente66cdce0fa4494572f0b9c4f613eee5601694e8c (diff)
parenta4febef1af478a57ce0de7784f25212ea97875a8 (diff)
downloadsandhi-bb756d67e039c1c8074e3da302786bf6759748a5.tar.gz
sandhi-bb756d67e039c1c8074e3da302786bf6759748a5.tar.bz2
sandhi-bb756d67e039c1c8074e3da302786bf6759748a5.zip
Merge branch 'libgras'
Diffstat (limited to 'include/gras/thread_pool.hpp')
-rw-r--r--include/gras/thread_pool.hpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/include/gras/thread_pool.hpp b/include/gras/thread_pool.hpp
new file mode 100644
index 0000000..57bfb48
--- /dev/null
+++ b/include/gras/thread_pool.hpp
@@ -0,0 +1,78 @@
+// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information.
+
+#ifndef INCLUDED_GRAS_THREAD_POOL_HPP
+#define INCLUDED_GRAS_THREAD_POOL_HPP
+
+#include <gras/gras.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+#include <string>
+
+//! ThreadPool is an unexposed Theron Framework
+//! Forward declare the Framwork for c++ users
+namespace Theron
+{
+ class Framework;
+}
+
+namespace gras
+{
+
+struct GRAS_API ThreadPoolConfig
+{
+ ThreadPoolConfig(void);
+
+ /*!
+ * The initial number of worker threads to create within the framework.
+ * Default is the number of CPUs on the system.
+ */
+ size_t thread_count;
+
+ /*!
+ * Specifies the NUMA processor nodes upon which the framework may execute.
+ * Default is all NUMA nodes on the system.
+ */
+ size_t node_mask;
+
+ /*!
+ * Specifies the subset of the processors in each NUMA processor node upon which the framework may execute.
+ * Default is all CPUs per NUMA node.
+ */
+ size_t processor_mask;
+
+ /*!
+ * Yield strategy employed by the worker threads in the framework.
+ * POLITE, ///< Threads go to sleep when not in use.
+ * STRONG, ///< Threads yield to other threads but don't go to sleep.
+ * AGGRESSIVE ///< Threads never yield to other threads.
+ * Default is STRONG.
+ */
+ std::string yield_strategy;
+};
+
+/*!
+ * Thread Pool is is a this wrapper of Theron Framework, see link for more details:
+ * http://docs.theron-library.com/5.00/structTheron_1_1Framework_1_1Parameters.html
+ */
+struct GRAS_API ThreadPool : boost::shared_ptr<Theron::Framework>
+{
+ //! Create an empty thread pool
+ ThreadPool(void);
+
+ //! Create a thread pool from a weak pointer to a framework
+ ThreadPool(boost::weak_ptr<Theron::Framework> p);
+
+ //! Create a new thread pool with parameters
+ ThreadPool(const ThreadPoolConfig &config);
+
+ /*!
+ * When a block is created, it will execute in the active pool.
+ * Use this call before creating a block to control which
+ * thread pool that the block's work routine will run in.
+ */
+ void set_active(void);
+};
+
+} //namespace gras
+
+#endif /*INCLUDED_GRAS_THREAD_POOL_HPP*/