diff options
author | Marc Laukien <marc@zeroc.com> | 2004-01-19 16:35:42 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2004-01-19 16:35:42 +0000 |
commit | 9adeb6ebe83379cee1966b9584a7d8ad086a8ab9 (patch) | |
tree | 6e94d10d6de31cac901eebea0277a3caa5f6a72f /cpp/test/IceStorm/federation/Subscriber.cpp | |
parent | fixed IceStorm test to not rely on sleep() (diff) | |
download | ice-9adeb6ebe83379cee1966b9584a7d8ad086a8ab9.tar.bz2 ice-9adeb6ebe83379cee1966b9584a7d8ad086a8ab9.tar.xz ice-9adeb6ebe83379cee1966b9584a7d8ad086a8ab9.zip |
fixed IceStorm test to not rely on sleep()
Diffstat (limited to 'cpp/test/IceStorm/federation/Subscriber.cpp')
-rw-r--r-- | cpp/test/IceStorm/federation/Subscriber.cpp | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/cpp/test/IceStorm/federation/Subscriber.cpp b/cpp/test/IceStorm/federation/Subscriber.cpp index c0b349ea7a7..c7ace5f3952 100644 --- a/cpp/test/IceStorm/federation/Subscriber.cpp +++ b/cpp/test/IceStorm/federation/Subscriber.cpp @@ -30,45 +30,39 @@ using namespace std; using namespace Ice; using namespace IceStorm; -class EventI : public Event, public IceUtil::Mutex +class EventI : public Event { public: EventI(const CommunicatorPtr& communicator) : - _communicator(communicator), - _count(0) + _communicator(communicator) { } virtual void pub(const string& data, const Ice::Current&) { - IceUtil::Mutex::Lock sync(*this); + IceUtil::StaticMutex::Lock sync(_countMutex); - if(data == "shutdown") + if(++_count == 30 + 40 + 30) { _communicator->shutdown(); - return; } - ++_count; - } - - int - count() const - { - IceUtil::Mutex::Lock sync(*this); - - return _count; } private: CommunicatorPtr _communicator; - int _count; + + static int _count; + static IceUtil::StaticMutex _countMutex; }; typedef IceUtil::Handle<EventI> EventIPtr; +int EventI::_count = 0; +IceUtil::StaticMutex EventI::_countMutex; + void createLock(const string& name) { @@ -192,10 +186,6 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) communicator->waitForShutdown(); - test(eventFed1->count() == 30); - test(eventFed2->count() == 40); - test(eventFed3->count() == 30); - deleteLock(lockfile); return EXIT_SUCCESS; |