summaryrefslogtreecommitdiff
path: root/cpp/test/Ice/acm/TestI.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2015-09-14 15:43:34 +0200
committerBenoit Foucher <benoit@zeroc.com>2015-09-14 15:43:34 +0200
commit13bed6dec104b53fadf723aead0dc15dc3f2afd8 (patch)
treed6401dbe7d70d65e04e448439e4056c1fa4d7e8c /cpp/test/Ice/acm/TestI.cpp
parentRemoved ARM configuraton from WinRT testsuite solutions (diff)
downloadice-13bed6dec104b53fadf723aead0dc15dc3f2afd8.tar.bz2
ice-13bed6dec104b53fadf723aead0dc15dc3f2afd8.tar.xz
ice-13bed6dec104b53fadf723aead0dc15dc3f2afd8.zip
Fixed ICE-6812 - JavaScript ACM monitor bug
Diffstat (limited to 'cpp/test/Ice/acm/TestI.cpp')
-rw-r--r--cpp/test/Ice/acm/TestI.cpp47
1 files changed, 44 insertions, 3 deletions
diff --git a/cpp/test/Ice/acm/TestI.cpp b/cpp/test/Ice/acm/TestI.cpp
index 2468f6ad1f1..869d204cf7e 100644
--- a/cpp/test/Ice/acm/TestI.cpp
+++ b/cpp/test/Ice/acm/TestI.cpp
@@ -60,8 +60,8 @@ RemoteCommunicatorI::shutdown(const Ice::Current& current)
current.adapter->getCommunicator()->shutdown();
}
-RemoteObjectAdapterI::RemoteObjectAdapterI(const Ice::ObjectAdapterPtr& adapter) :
- _adapter(adapter),
+RemoteObjectAdapterI::RemoteObjectAdapterI(const Ice::ObjectAdapterPtr& adapter) :
+ _adapter(adapter),
_testIntf(TestIntfPrx::uncheckedCast(_adapter->add(new TestI(),
adapter->getCommunicator()->stringToIdentity("test"))))
{
@@ -113,9 +113,50 @@ TestI::sleepAndHold(int delay, const Ice::Current& current)
timedWait(IceUtil::Time::seconds(delay));
}
-void
+void
TestI::interruptSleep(const Ice::Current& current)
{
Lock sync(*this);
notifyAll();
}
+
+void
+TestI::waitForHeartbeat(int count, const Ice::Current& current)
+{
+ class ConnectionCallbackI : public Ice::ConnectionCallback, private IceUtil::Monitor<IceUtil::Mutex>
+ {
+ public:
+
+ void
+ waitForCount(int count)
+ {
+ Lock sync(*this);
+ _count = count;
+ while(_count > 0)
+ {
+ wait();
+ }
+ }
+
+ private:
+
+ virtual void
+ heartbeat(const Ice::ConnectionPtr&)
+ {
+ Lock sync(*this);
+ --_count;
+ notifyAll();
+ }
+
+ virtual void
+ closed(const Ice::ConnectionPtr&)
+ {
+ }
+
+ int _count;
+ };
+
+ IceUtil::Handle<ConnectionCallbackI> callback = new ConnectionCallbackI();
+ current.con->setCallback(callback);
+ callback->waitForCount(count);
+} \ No newline at end of file