diff options
author | Daniil Cherednik <[email protected]> | 2022-09-21 20:17:38 +0300 |
---|---|---|
committer | Daniil Cherednik <[email protected]> | 2022-09-21 20:17:38 +0300 |
commit | e6c9b17192c56494adba359d5e132c431b241191 (patch) | |
tree | 6f2449871a118a0e8919ce842b1174e06cb470ef /contrib/restricted/boost/libs/context/src/continuation.cpp | |
parent | 285021ab1aac39e84b269d9bacd4deee69cf63fc (diff) |
Ydb stable 22-4-2122.4.21
x-stable-origin-commit: e89099581237299a132feafb5b58af59ebd0468a
Diffstat (limited to 'contrib/restricted/boost/libs/context/src/continuation.cpp')
-rw-r--r-- | contrib/restricted/boost/libs/context/src/continuation.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/contrib/restricted/boost/libs/context/src/continuation.cpp b/contrib/restricted/boost/libs/context/src/continuation.cpp new file mode 100644 index 00000000000..0779baaba87 --- /dev/null +++ b/contrib/restricted/boost/libs/context/src/continuation.cpp @@ -0,0 +1,60 @@ + +// Copyright Oliver Kowalke 2017. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#if defined(BOOST_USE_UCONTEXT) +#include "boost/context/continuation_ucontext.hpp" +#elif defined(BOOST_USE_WINFIB) +#include "boost/context/continuation_winfib.hpp" +#else +#include "boost/context/execution_context.hpp" +#endif + +#include <boost/config.hpp> + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +namespace boost { +namespace context { +namespace detail { + +// zero-initialization +thread_local activation_record * current_rec; +thread_local static std::size_t counter; + +// schwarz counter +activation_record_initializer::activation_record_initializer() noexcept { + if ( 0 == counter++) { + current_rec = new activation_record(); + } +} + +activation_record_initializer::~activation_record_initializer() { + if ( 0 == --counter) { + BOOST_ASSERT( current_rec->is_main_context() ); + delete current_rec; + } +} + +} + +namespace detail { + +activation_record *& +activation_record::current() noexcept { + // initialized the first time control passes; per thread + thread_local static activation_record_initializer initializer; + return current_rec; +} + +} + +}} + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif |