diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/qpid/sys/Serializer.cpp | 15 | ||||
-rw-r--r-- | cpp/src/qpid/sys/Serializer.h | 2 |
2 files changed, 14 insertions, 3 deletions
diff --git a/cpp/src/qpid/sys/Serializer.cpp b/cpp/src/qpid/sys/Serializer.cpp index f02e51ddb4..a82982a0c8 100644 --- a/cpp/src/qpid/sys/Serializer.cpp +++ b/cpp/src/qpid/sys/Serializer.cpp @@ -51,11 +51,20 @@ void SerializerBase::notifyWorker() { lock.notify(); } -void SerializerBase::run() { +bool SerializerBase::running() { + Mutex::ScopedLock l(lock); + return state != SHUTDOWN; +} + +void SerializerBase::wait() { Mutex::ScopedLock l(lock); - while (state != SHUTDOWN) { + lock.wait(); +} + +void SerializerBase::run() { + while (running()) { dispatch(); - lock.wait(); + wait(); } } diff --git a/cpp/src/qpid/sys/Serializer.h b/cpp/src/qpid/sys/Serializer.h index 30b7f88505..fe4afc85cb 100644 --- a/cpp/src/qpid/sys/Serializer.h +++ b/cpp/src/qpid/sys/Serializer.h @@ -61,6 +61,8 @@ class SerializerBase : private boost::noncopyable, private Runnable void notifyWorker(); void run(); virtual bool empty() = 0; + bool running(); + void wait(); Monitor lock; State state; |