diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
commit | 718c552901d703c502ccbefdfc3c9028d608b947 (patch) | |
tree | 46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/libs/poco/Foundation/include/Poco/ActiveRunnable.h | |
parent | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff) | |
download | ydb-718c552901d703c502ccbefdfc3c9028d608b947.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/poco/Foundation/include/Poco/ActiveRunnable.h')
-rw-r--r-- | contrib/libs/poco/Foundation/include/Poco/ActiveRunnable.h | 462 |
1 files changed, 231 insertions, 231 deletions
diff --git a/contrib/libs/poco/Foundation/include/Poco/ActiveRunnable.h b/contrib/libs/poco/Foundation/include/Poco/ActiveRunnable.h index 95317b0b3f..ca8d9431c3 100644 --- a/contrib/libs/poco/Foundation/include/Poco/ActiveRunnable.h +++ b/contrib/libs/poco/Foundation/include/Poco/ActiveRunnable.h @@ -1,231 +1,231 @@ -// -// ActiveRunnable.h -// -// Library: Foundation -// Package: Threading -// Module: ActiveObjects -// -// Definition of the ActiveRunnable class. -// -// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_ActiveRunnable_INCLUDED -#define Foundation_ActiveRunnable_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/ActiveResult.h" -#include "Poco/Runnable.h" -#include "Poco/RefCountedObject.h" -#include "Poco/AutoPtr.h" -#include "Poco/Exception.h" - - -namespace Poco { - - -class ActiveRunnableBase: public Runnable, public RefCountedObject - /// The base class for all ActiveRunnable instantiations. -{ -public: - typedef AutoPtr<ActiveRunnableBase> Ptr; -}; - - -template <class ResultType, class ArgType, class OwnerType> -class ActiveRunnable: public ActiveRunnableBase - /// This class is used by ActiveMethod. - /// See the ActiveMethod class for more information. -{ -public: - typedef ResultType (OwnerType::*Callback)(const ArgType&); - typedef ActiveResult<ResultType> ActiveResultType; - - ActiveRunnable(OwnerType* pOwner, Callback method, const ArgType& arg, const ActiveResultType& result): - _pOwner(pOwner), - _method(method), - _arg(arg), - _result(result) - { - poco_check_ptr (pOwner); - } - - void run() - { - ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done - try - { - _result.data(new ResultType((_pOwner->*_method)(_arg))); - } - catch (Exception& e) - { - _result.error(e); - } - catch (std::exception& e) - { - _result.error(e.what()); - } - catch (...) - { - _result.error("unknown exception"); - } - _result.notify(); - } - -private: - OwnerType* _pOwner; - Callback _method; - ArgType _arg; - ActiveResultType _result; -}; - - -template <class ArgType, class OwnerType> -class ActiveRunnable<void, ArgType, OwnerType>: public ActiveRunnableBase - /// This class is used by ActiveMethod. - /// See the ActiveMethod class for more information. -{ -public: - typedef void (OwnerType::*Callback)(const ArgType&); - typedef ActiveResult<void> ActiveResultType; - - ActiveRunnable(OwnerType* pOwner, Callback method, const ArgType& arg, const ActiveResultType& result): - _pOwner(pOwner), - _method(method), - _arg(arg), - _result(result) - { - poco_check_ptr (pOwner); - } - - void run() - { - ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done - try - { - (_pOwner->*_method)(_arg); - } - catch (Exception& e) - { - _result.error(e); - } - catch (std::exception& e) - { - _result.error(e.what()); - } - catch (...) - { - _result.error("unknown exception"); - } - _result.notify(); - } - -private: - OwnerType* _pOwner; - Callback _method; - ArgType _arg; - ActiveResultType _result; -}; - - -template <class ResultType, class OwnerType> -class ActiveRunnable<ResultType, void, OwnerType>: public ActiveRunnableBase - /// This class is used by ActiveMethod. - /// See the ActiveMethod class for more information. -{ -public: - typedef ResultType (OwnerType::*Callback)(); - typedef ActiveResult<ResultType> ActiveResultType; - - ActiveRunnable(OwnerType* pOwner, Callback method, const ActiveResultType& result): - _pOwner(pOwner), - _method(method), - _result(result) - { - poco_check_ptr (pOwner); - } - - void run() - { - ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done - try - { - _result.data(new ResultType((_pOwner->*_method)())); - } - catch (Exception& e) - { - _result.error(e); - } - catch (std::exception& e) - { - _result.error(e.what()); - } - catch (...) - { - _result.error("unknown exception"); - } - _result.notify(); - } - -private: - OwnerType* _pOwner; - Callback _method; - ActiveResultType _result; -}; - - -template <class OwnerType> -class ActiveRunnable<void, void, OwnerType>: public ActiveRunnableBase - /// This class is used by ActiveMethod. - /// See the ActiveMethod class for more information. -{ -public: - typedef void (OwnerType::*Callback)(); - typedef ActiveResult<void> ActiveResultType; - - ActiveRunnable(OwnerType* pOwner, Callback method, const ActiveResultType& result): - _pOwner(pOwner), - _method(method), - _result(result) - { - poco_check_ptr (pOwner); - } - - void run() - { - ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done - try - { - (_pOwner->*_method)(); - } - catch (Exception& e) - { - _result.error(e); - } - catch (std::exception& e) - { - _result.error(e.what()); - } - catch (...) - { - _result.error("unknown exception"); - } - _result.notify(); - } - -private: - OwnerType* _pOwner; - Callback _method; - ActiveResultType _result; -}; - - -} // namespace Poco - - -#endif // Foundation_ActiveRunnable_INCLUDED +// +// ActiveRunnable.h +// +// Library: Foundation +// Package: Threading +// Module: ActiveObjects +// +// Definition of the ActiveRunnable class. +// +// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef Foundation_ActiveRunnable_INCLUDED +#define Foundation_ActiveRunnable_INCLUDED + + +#include "Poco/Foundation.h" +#include "Poco/ActiveResult.h" +#include "Poco/Runnable.h" +#include "Poco/RefCountedObject.h" +#include "Poco/AutoPtr.h" +#include "Poco/Exception.h" + + +namespace Poco { + + +class ActiveRunnableBase: public Runnable, public RefCountedObject + /// The base class for all ActiveRunnable instantiations. +{ +public: + typedef AutoPtr<ActiveRunnableBase> Ptr; +}; + + +template <class ResultType, class ArgType, class OwnerType> +class ActiveRunnable: public ActiveRunnableBase + /// This class is used by ActiveMethod. + /// See the ActiveMethod class for more information. +{ +public: + typedef ResultType (OwnerType::*Callback)(const ArgType&); + typedef ActiveResult<ResultType> ActiveResultType; + + ActiveRunnable(OwnerType* pOwner, Callback method, const ArgType& arg, const ActiveResultType& result): + _pOwner(pOwner), + _method(method), + _arg(arg), + _result(result) + { + poco_check_ptr (pOwner); + } + + void run() + { + ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done + try + { + _result.data(new ResultType((_pOwner->*_method)(_arg))); + } + catch (Exception& e) + { + _result.error(e); + } + catch (std::exception& e) + { + _result.error(e.what()); + } + catch (...) + { + _result.error("unknown exception"); + } + _result.notify(); + } + +private: + OwnerType* _pOwner; + Callback _method; + ArgType _arg; + ActiveResultType _result; +}; + + +template <class ArgType, class OwnerType> +class ActiveRunnable<void, ArgType, OwnerType>: public ActiveRunnableBase + /// This class is used by ActiveMethod. + /// See the ActiveMethod class for more information. +{ +public: + typedef void (OwnerType::*Callback)(const ArgType&); + typedef ActiveResult<void> ActiveResultType; + + ActiveRunnable(OwnerType* pOwner, Callback method, const ArgType& arg, const ActiveResultType& result): + _pOwner(pOwner), + _method(method), + _arg(arg), + _result(result) + { + poco_check_ptr (pOwner); + } + + void run() + { + ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done + try + { + (_pOwner->*_method)(_arg); + } + catch (Exception& e) + { + _result.error(e); + } + catch (std::exception& e) + { + _result.error(e.what()); + } + catch (...) + { + _result.error("unknown exception"); + } + _result.notify(); + } + +private: + OwnerType* _pOwner; + Callback _method; + ArgType _arg; + ActiveResultType _result; +}; + + +template <class ResultType, class OwnerType> +class ActiveRunnable<ResultType, void, OwnerType>: public ActiveRunnableBase + /// This class is used by ActiveMethod. + /// See the ActiveMethod class for more information. +{ +public: + typedef ResultType (OwnerType::*Callback)(); + typedef ActiveResult<ResultType> ActiveResultType; + + ActiveRunnable(OwnerType* pOwner, Callback method, const ActiveResultType& result): + _pOwner(pOwner), + _method(method), + _result(result) + { + poco_check_ptr (pOwner); + } + + void run() + { + ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done + try + { + _result.data(new ResultType((_pOwner->*_method)())); + } + catch (Exception& e) + { + _result.error(e); + } + catch (std::exception& e) + { + _result.error(e.what()); + } + catch (...) + { + _result.error("unknown exception"); + } + _result.notify(); + } + +private: + OwnerType* _pOwner; + Callback _method; + ActiveResultType _result; +}; + + +template <class OwnerType> +class ActiveRunnable<void, void, OwnerType>: public ActiveRunnableBase + /// This class is used by ActiveMethod. + /// See the ActiveMethod class for more information. +{ +public: + typedef void (OwnerType::*Callback)(); + typedef ActiveResult<void> ActiveResultType; + + ActiveRunnable(OwnerType* pOwner, Callback method, const ActiveResultType& result): + _pOwner(pOwner), + _method(method), + _result(result) + { + poco_check_ptr (pOwner); + } + + void run() + { + ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done + try + { + (_pOwner->*_method)(); + } + catch (Exception& e) + { + _result.error(e); + } + catch (std::exception& e) + { + _result.error(e.what()); + } + catch (...) + { + _result.error("unknown exception"); + } + _result.notify(); + } + +private: + OwnerType* _pOwner; + Callback _method; + ActiveResultType _result; +}; + + +} // namespace Poco + + +#endif // Foundation_ActiveRunnable_INCLUDED |