1 // **********************************************************************
3 // Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
8 // **********************************************************************
11 #include <IceUtil/IceUtil.h>
13 #include <TestCommon.h>
15 HoldI::HoldI(const IceUtil::TimerPtr
& timer
, const Ice::ObjectAdapterPtr
& adapter
) :
16 _last(0), _timer(timer
), _adapter(adapter
)
21 HoldI::putOnHold(Ice::Int milliSeconds
, const Ice::Current
&)
27 else if(milliSeconds
== 0)
36 _timer
->schedule(this, IceUtil::Time::milliSeconds(milliSeconds
));
38 catch(const IceUtil::IllegalArgumentException
&)
45 HoldI::waitForHold(const Ice::Current
& current
)
47 class WaitForHold
: public IceUtil::TimerTask
51 WaitForHold(const Ice::ObjectAdapterPtr
& adapter
) : _adapter(adapter
)
60 _adapter
->waitForHold();
63 catch(const Ice::ObjectAdapterDeactivatedException
&)
66 // This shouldn't occur. The test ensures all the waitForHold timers are
67 // finished before shutting down the communicator.
75 const Ice::ObjectAdapterPtr _adapter
;
80 _timer
->schedule(new WaitForHold(current
.adapter
), IceUtil::Time());
82 catch(const IceUtil::IllegalArgumentException
&)
88 HoldI::set(Ice::Int value
, Ice::Int delay
, const Ice::Current
&)
90 IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(delay
));
99 HoldI::setOneway(Ice::Int value
, Ice::Int expected
, const Ice::Current
&)
102 test(_last
== expected
);
107 HoldI::shutdown(const Ice::Current
&)
110 _adapter
->getCommunicator()->shutdown();
114 HoldI::runTimerTask()
119 _adapter
->activate();
121 catch(const Ice::ObjectAdapterDeactivatedException
&)