diff options
Diffstat (limited to 'cpp/test/Ice/acm/TestI.cpp')
-rw-r--r-- | cpp/test/Ice/acm/TestI.cpp | 50 |
1 files changed, 11 insertions, 39 deletions
diff --git a/cpp/test/Ice/acm/TestI.cpp b/cpp/test/Ice/acm/TestI.cpp index d7742680a70..f4987856421 100644 --- a/cpp/test/Ice/acm/TestI.cpp +++ b/cpp/test/Ice/acm/TestI.cpp @@ -26,41 +26,6 @@ toString(int value) return os.str(); } -class HeartbeatCallbackI : -#ifdef ICE_CPP11_MAPPING - public enable_shared_from_this<HeartbeatCallbackI>, -#else - public Ice::HeartbeatCallback, -#endif - private IceUtil::Monitor<IceUtil::Mutex> -{ -public: - - void - waitForCount(int count) - { - Lock sync(*this); - _count = count; - while(_count > 0) - { - wait(); - } - } - - virtual void - heartbeat(const Ice::ConnectionPtr&) - { - Lock sync(*this); - --_count; - notifyAll(); - } - -private: - - int _count; -}; -ICE_DEFINE_PTR(HeartbeatCallbackIPtr, HeartbeatCallbackI); - } RemoteObjectAdapterPrxPtr @@ -162,16 +127,23 @@ TestI::interruptSleep(const Ice::Current& current) } void -TestI::waitForHeartbeat(int count, const Ice::Current& current) +TestI::startHeartbeatCount(const Ice::Current& current) { - HeartbeatCallbackIPtr callback = ICE_MAKE_SHARED(HeartbeatCallbackI); + _callback = ICE_MAKE_SHARED(HeartbeatCallbackI); #ifdef ICE_CPP11_MAPPING + HeartbeatCallbackIPtr callback = _callback; current.con->setHeartbeatCallback([callback](Ice::ConnectionPtr connection) { callback->heartbeat(move(connection)); }); #else - current.con->setHeartbeatCallback(callback); + current.con->setHeartbeatCallback(_callback); #endif - callback->waitForCount(count); +} + +void +TestI::waitForHeartbeatCount(int count, const Ice::Current&) +{ + assert(_callback); + _callback->waitForCount(count); } |