diff options
Diffstat (limited to 'cpp/test/Ice/background/Configuration.cpp')
-rw-r--r-- | cpp/test/Ice/background/Configuration.cpp | 182 |
1 files changed, 182 insertions, 0 deletions
diff --git a/cpp/test/Ice/background/Configuration.cpp b/cpp/test/Ice/background/Configuration.cpp new file mode 100644 index 00000000000..d2f7e82a1c1 --- /dev/null +++ b/cpp/test/Ice/background/Configuration.cpp @@ -0,0 +1,182 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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 <Configuration.h> + +Configuration* Configuration::_instance = 0; + +Configuration::Configuration() : + _initializeSocketStatus(IceInternal::Finished), + _initializeResetCount(0), + _readReadyCount(0), + _writeReadyCount(0) +{ + assert(!_instance); + _instance = this; +} + +Configuration::~Configuration() +{ + _instance = 0; +} + +void +Configuration::connectorsException(Ice::LocalException* ex) +{ + Lock sync(*this); + _connectorsException.reset(ex); +} + +void +Configuration::checkConnectorsException() +{ + Lock sync(*this); + if(_connectorsException.get()) + { + _connectorsException->ice_throw(); + } +} + +void +Configuration::connectException(Ice::LocalException* ex) +{ + Lock sync(*this); + _connectException.reset(ex); +} + +void +Configuration::checkConnectException() +{ + Lock sync(*this); + if(_connectException.get()) + { + _connectException->ice_throw(); + } +} + +void +Configuration::initializeSocketStatus(IceInternal::SocketStatus status) +{ + Lock sync(*this); + if(status == IceInternal::Finished) + { + _initializeResetCount = 0; + return; + } + _initializeResetCount = 10; + _initializeSocketStatus = status; +} + +void +Configuration::initializeException(Ice::LocalException* ex) +{ + Lock sync(*this); + _initializeException.reset(ex); +} + +IceInternal::SocketStatus +Configuration::initializeSocketStatus() +{ + Lock sync(*this); + if(_initializeResetCount == 0) + { + return IceInternal::Finished; + } + --_initializeResetCount; + return _initializeSocketStatus; +} + +void +Configuration::checkInitializeException() +{ + Lock sync(*this); + if(_initializeException.get()) + { + _initializeException->ice_throw(); + } +} + +void +Configuration::readReady(bool ready) +{ + Lock sync(*this); + _readReadyCount = ready ? 0 : 10; +} + +void +Configuration::readException(Ice::LocalException* ex) +{ + Lock sync(*this); + _readException.reset(ex); +} + +bool +Configuration::readReady() +{ + Lock sync(*this); + if(_readReadyCount == 0) + { + return true; + } + --_readReadyCount; + return false; +} + +void +Configuration::checkReadException() +{ + Lock sync(*this); + if(_readException.get()) + { + _readException->ice_throw(); + } +} + +void +Configuration::writeReady(bool ready) +{ + Lock sync(*this); + _writeReadyCount = ready ? 0 : 10; +} + +void +Configuration::writeException(Ice::LocalException* ex) +{ + Lock sync(*this); + _writeException.reset(ex); +} + +bool +Configuration::writeReady() +{ + Lock sync(*this); + if(_writeReadyCount == 0) + { + return true; + } + --_writeReadyCount; + return false; +} + +void +Configuration::checkWriteException() +{ + Lock sync(*this); + if(_writeException.get()) + { + _writeException->ice_throw(); + } +} + +Configuration* +Configuration::getInstance() +{ + return _instance; +} + |