summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/ThreadPool.h
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/Ice/ThreadPool.h')
-rw-r--r--cpp/src/Ice/ThreadPool.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/cpp/src/Ice/ThreadPool.h b/cpp/src/Ice/ThreadPool.h
new file mode 100644
index 00000000000..71983722237
--- /dev/null
+++ b/cpp/src/Ice/ThreadPool.h
@@ -0,0 +1,78 @@
+// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_THREAD_POOL_H
+#define ICE_THREAD_POOL_H
+
+#include <Ice/ThreadPoolF.h>
+#include <Ice/InstanceF.h>
+#include <Ice/EventHandlerF.h>
+#include <Ice/Shared.h>
+#include <map>
+
+namespace IceInternal
+{
+
+class Stream;
+
+class ThreadPool : public Shared, public JTCMonitorT<JTCMutex>
+{
+public:
+
+ void _register(int, const EventHandlerPtr&);
+ void unregister(int);
+ void promoteFollower();
+ void waitUntilServerFinished();
+ void waitUntilFinished();
+ void joinWithAllThreads();
+
+private:
+
+ ThreadPool(const InstancePtr&);
+ virtual ~ThreadPool();
+ void destroy();
+ friend class Instance;
+
+ void clearInterrupt();
+ void setInterrupt();
+
+ void run();
+ void read(const EventHandlerPtr&);
+
+ InstancePtr _instance;
+ int _lastFd;
+ int _maxFd;
+ int _fdIntrRead;
+ int _fdIntrWrite;
+ fd_set _fdSet;
+ std::vector<std::pair<int, EventHandlerPtr> > _adds;
+ std::vector<int> _removes;
+ std::map<int, EventHandlerPtr> _handlers;
+ int _servers;
+ JTCMutex _threadMutex;
+
+ class EventHandlerThread : public JTCThread
+ {
+ public:
+
+ EventHandlerThread(ThreadPoolPtr pool) : _pool(pool) { }
+ virtual void run();
+
+ private:
+
+ ThreadPoolPtr _pool;
+ };
+ friend class EventHandlerThread;
+ std::vector<JTCThreadHandle> _threads;
+};
+
+}
+
+#endif