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.h43
1 files changed, 27 insertions, 16 deletions
diff --git a/cpp/src/Ice/ThreadPool.h b/cpp/src/Ice/ThreadPool.h
index e46f244dce1..005a19459df 100644
--- a/cpp/src/Ice/ThreadPool.h
+++ b/cpp/src/Ice/ThreadPool.h
@@ -23,6 +23,8 @@
#include <Ice/EventHandler.h>
#include <Ice/Selector.h>
#include <Ice/BasicStream.h>
+#include <Ice/ObserverHelper.h>
+#include <Ice/Observer.h>
#include <set>
#include <list>
@@ -37,6 +39,24 @@ typedef IceUtil::Handle<ThreadPoolWorkQueue> ThreadPoolWorkQueuePtr;
class ThreadPool : public IceUtil::Shared, public IceUtil::Monitor<IceUtil::Mutex>
{
+ class EventHandlerThread : public IceUtil::Thread
+ {
+ public:
+
+ EventHandlerThread(const ThreadPoolPtr&);
+ virtual void run();
+
+ void updateObserver();
+ void setState(Ice::Instrumentation::ThreadState);
+
+ private:
+
+ ThreadPoolPtr _pool;
+ ObserverHelperT<Ice::Instrumentation::ThreadObserver> _observer;
+ Ice::Instrumentation::ThreadState _state;
+ };
+ typedef IceUtil::Handle<EventHandlerThread> EventHandlerThreadPtr;
+
public:
ThreadPool(const InstancePtr&, const std::string&, int);
@@ -44,6 +64,8 @@ public:
void destroy();
+ void updateObservers();
+
void initialize(const EventHandlerPtr&);
void _register(const EventHandlerPtr& handler, SocketOperation status)
{
@@ -63,7 +85,7 @@ public:
private:
- void run(const IceUtil::ThreadPtr&);
+ void run(const EventHandlerThreadPtr&);
bool ioCompleted(ThreadPoolCurrent&);
@@ -72,7 +94,7 @@ private:
void finishMessage(ThreadPoolCurrent&);
#else
void promoteFollower(ThreadPoolCurrent&);
- bool followerWait(const IceUtil::ThreadPtr&, ThreadPoolCurrent&);
+ bool followerWait(ThreadPoolCurrent&);
#endif
const InstancePtr _instance;
@@ -81,18 +103,6 @@ private:
const std::string _prefix;
Selector _selector;
- class EventHandlerThread : public IceUtil::Thread
- {
- public:
-
- EventHandlerThread(const ThreadPoolPtr&);
- virtual void run();
-
- private:
-
- ThreadPoolPtr _pool;
- };
-
friend class EventHandlerThread;
friend class ThreadPoolCurrent;
@@ -107,7 +117,7 @@ private:
const int _threadIdleTime;
const size_t _stackSize;
- std::set<IceUtil::ThreadPtr> _threads; // All threads, running or not.
+ std::set<EventHandlerThreadPtr> _threads; // All threads, running or not.
int _inUse; // Number of threads that are currently in use.
#if !defined(ICE_USE_IOCP) && !defined(ICE_OS_WINRT)
int _inUseIO; // Number of threads that are currently performing IO.
@@ -122,7 +132,7 @@ class ThreadPoolCurrent
{
public:
- ThreadPoolCurrent(const InstancePtr&, const ThreadPoolPtr&);
+ ThreadPoolCurrent(const InstancePtr&, const ThreadPoolPtr&, const ThreadPool::EventHandlerThreadPtr&);
SocketOperation operation;
BasicStream stream; // A per-thread stream to be used by event handlers for optimization.
@@ -147,6 +157,7 @@ public:
private:
ThreadPool* _threadPool;
+ ThreadPool::EventHandlerThreadPtr _thread;
EventHandlerPtr _handler;
bool _ioCompleted;
#if !defined(ICE_USE_IOCP) && !defined(ICE_OS_WINRT)