Checkpoint of initial cut at thread pool manager for thrift and related concurrency classes.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664721 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/concurrency/PosixThreadFactory.h b/lib/cpp/src/concurrency/PosixThreadFactory.h
new file mode 100644
index 0000000..88a0888
--- /dev/null
+++ b/lib/cpp/src/concurrency/PosixThreadFactory.h
@@ -0,0 +1,76 @@
+#if !defined(_concurrency_PosixThreadFactory_h_)
+#define _concurrency_PosixThreadFactory_h_ 1
+
+#include "Thread.h"
+
+namespace facebook { namespace thrift { namespace concurrency {
+
+/** A thread factory to create posix threads
+
+ @author marc */
+
+class PosixThreadFactory : public ThreadFactory {
+
+ public:
+
+ /** POSIX Thread scheduler policies */
+
+ enum POLICY {
+ OTHER,
+ FIFO,
+ ROUND_ROBIN
+ };
+
+ /** POSIX Thread scheduler relative priorities,
+
+ Absolute priority is determined by scheduler policy and OS. This enumeration specifies relative priorities such that one can
+ specify a priority withing a giving scheduler policy without knowing the absolute value of the priority. */
+
+ enum PRIORITY {
+ LOWEST = 0,
+ LOWER = 1,
+ LOW = 2,
+ NORMAL = 3,
+ HIGH = 4,
+ HIGHER = 5,
+ HIGHEST = 6,
+ INCREMENT = 7,
+ DECREMENT = 8
+ };
+
+ PosixThreadFactory(POLICY policy=ROUND_ROBIN, PRIORITY priority=NORMAL, int stackSize=1, bool detached=false);
+
+ // From ThreadFactory;
+
+ Thread* newThread(Runnable* runnable) const;
+
+ /** Sets stack size for created threads
+
+ @param value size in megabytes */
+
+ virtual void stackSize(int value);
+
+ /** Gets stack size for created threads
+
+ @return int size in megabytes */
+
+ virtual int stackSize() const;
+
+ /** Sets priority relative to current policy */
+
+ virtual void priority(PRIORITY priority);
+
+ /** Gets priority relative to current policy */
+
+ virtual PRIORITY priority() const;
+
+ private:
+
+ class Impl;
+
+ Impl* _impl;
+};
+
+}}} // facebook::thrift::concurrency
+
+#endif // !defined(_concurrency_PosixThreadFactory_h_)