diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /contrib/libs/poco/Foundation/include/Poco/ThreadTarget.h | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'contrib/libs/poco/Foundation/include/Poco/ThreadTarget.h')
-rw-r--r-- | contrib/libs/poco/Foundation/include/Poco/ThreadTarget.h | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/contrib/libs/poco/Foundation/include/Poco/ThreadTarget.h b/contrib/libs/poco/Foundation/include/Poco/ThreadTarget.h new file mode 100644 index 0000000000..88452694c9 --- /dev/null +++ b/contrib/libs/poco/Foundation/include/Poco/ThreadTarget.h @@ -0,0 +1,87 @@ +// +// ThreadTarget.h +// +// Library: Foundation +// Package: Threading +// Module: ThreadTarget +// +// Definition of the ThreadTarget class. +// +// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef Foundation_ThreadTarget_INCLUDED +#define Foundation_ThreadTarget_INCLUDED + + +#include "Poco/Foundation.h" +#include "Poco/Runnable.h" + + +namespace Poco { + + +class Foundation_API ThreadTarget: public Runnable + /// This adapter simplifies using static member functions as well as + /// standalone functions as targets for threads. + /// Note that it is possible to pass those entities directly to Thread::start(). + /// This adapter is provided as a convenience for higher abstraction level + /// scenarios where Runnable abstract class is used. + /// + /// For using a non-static member function as a thread target, please + /// see the RunnableAdapter class. + /// + /// Usage: + /// class MyObject + /// { + /// static void doSomething() {} + /// }; + /// ThreadTarget ra(&MyObject::doSomething); + /// Thread thr; + /// thr.start(ra); + /// + /// or: + /// + /// void doSomething() {} + /// + /// ThreadTarget ra(doSomething); + /// Thread thr; + /// thr.start(ra); +{ +public: + typedef void (*Callback)(); + + ThreadTarget(Callback method); + + ThreadTarget(const ThreadTarget& te); + + ~ThreadTarget(); + + ThreadTarget& operator = (const ThreadTarget& te); + + void run(); + +private: + ThreadTarget(); + + Callback _method; +}; + + +// +// inlines +// +inline void ThreadTarget::run() +{ + _method(); +} + + +} // namespace Poco + + +#endif // Foundation_ThreadTarget_INCLUDED |