// ********************************************************************** // // Copyright (c) 2003-2008 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 #include #include #include HoldI::HoldI(const IceUtil::TimerPtr& timer, const Ice::ObjectAdapterPtr& adapter) : _last(0), _timer(timer), _adapter(adapter) { } void HoldI::putOnHold(Ice::Int milliSeconds, const Ice::Current&) { if(milliSeconds <= 0) { _adapter->hold(); _adapter->activate(); } else { try { _timer->schedule(this, IceUtil::Time::milliSeconds(milliSeconds)); } catch(const IceUtil::IllegalArgumentException&) { } } } Ice::Int HoldI::set(Ice::Int value, const Ice::Current&) { IceUtil::ThreadControl::yield(); Lock sync(*this); Ice::Int tmp = _last; _last = value; return tmp; } void HoldI::setOneway(Ice::Int value, Ice::Int expected, const Ice::Current&) { Lock sync(*this); test(_last == expected); _last = value; } void HoldI::shutdown(const Ice::Current&) { _adapter->hold(); _adapter->getCommunicator()->shutdown(); } void HoldI::runTimerTask() { try { _adapter->hold(); _adapter->activate(); } catch(const Ice::ObjectAdapterDeactivatedException&) { } }