summaryrefslogtreecommitdiff
path: root/cpp/test/Ice/timeout/TestI.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2006-04-04 18:27:58 +0000
committerMark Spruiell <mes@zeroc.com>2006-04-04 18:27:58 +0000
commit832d17da69cb833ca0dadc0113ce893078601580 (patch)
tree16d799b4779ab8f6e28b64200d25a61eadc1877a /cpp/test/Ice/timeout/TestI.cpp
parentminor fixes (diff)
downloadice-832d17da69cb833ca0dadc0113ce893078601580.tar.bz2
ice-832d17da69cb833ca0dadc0113ce893078601580.tar.xz
ice-832d17da69cb833ca0dadc0113ce893078601580.zip
adding timeout test
Diffstat (limited to 'cpp/test/Ice/timeout/TestI.cpp')
-rw-r--r--cpp/test/Ice/timeout/TestI.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/cpp/test/Ice/timeout/TestI.cpp b/cpp/test/Ice/timeout/TestI.cpp
new file mode 100644
index 00000000000..03cfd0c95b1
--- /dev/null
+++ b/cpp/test/Ice/timeout/TestI.cpp
@@ -0,0 +1,67 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#include <TestI.h>
+#include <Ice/Ice.h>
+#include <IceUtil/Thread.h>
+
+using namespace std;
+using namespace Ice;
+
+class ActivateAdapterThread : public IceUtil::Thread
+{
+public:
+
+ ActivateAdapterThread(const ObjectAdapterPtr& adapter, int timeout) :
+ _adapter(adapter), _timeout(timeout)
+ {
+ }
+
+ virtual void
+ run()
+ {
+ IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(_timeout));
+ _adapter->activate();
+ }
+
+private:
+
+ ObjectAdapterPtr _adapter;
+ int _timeout;
+};
+
+void
+TimeoutI::op(const Ice::Current&)
+{
+}
+
+void
+TimeoutI::sendData(const Test::ByteSeq&, const Ice::Current&)
+{
+}
+
+void
+TimeoutI::sleep(Ice::Int to, const Ice::Current&)
+{
+ IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(to));
+}
+
+void
+TimeoutI::holdAdapter(Ice::Int to, const Ice::Current& current)
+{
+ current.adapter->hold();
+ IceUtil::ThreadPtr thread = new ActivateAdapterThread(current.adapter, to);
+ thread->start();
+}
+
+void
+TimeoutI::shutdown(const Ice::Current& current)
+{
+ current.adapter->getCommunicator()->shutdown();
+}