]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/context/src/continuation.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / context / src / continuation.cpp
1
2 // Copyright Oliver Kowalke 2017.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6
7 #if defined(BOOST_USE_UCONTEXT)
8 #include "boost/context/continuation_ucontext.hpp"
9 #elif defined(BOOST_USE_WINFIB)
10 #include "boost/context/continuation_winfib.hpp"
11 #endif
12
13 #include <boost/config.hpp>
14
15 #ifdef BOOST_HAS_ABI_HEADERS
16 # include BOOST_ABI_PREFIX
17 #endif
18
19 namespace boost {
20 namespace context {
21 namespace detail {
22
23 // zero-initialization
24 thread_local activation_record * current_rec;
25 thread_local static std::size_t counter;
26
27 // schwarz counter
28 activation_record_initializer::activation_record_initializer() noexcept {
29 if ( 0 == counter++) {
30 current_rec = new activation_record();
31 }
32 }
33
34 activation_record_initializer::~activation_record_initializer() {
35 if ( 0 == --counter) {
36 BOOST_ASSERT( current_rec->is_main_context() );
37 delete current_rec;
38 }
39 }
40
41 }
42
43 namespace detail {
44
45 activation_record *&
46 activation_record::current() noexcept {
47 // initialized the first time control passes; per thread
48 thread_local static activation_record_initializer initializer;
49 return current_rec;
50 }
51
52 }
53
54 }}
55
56 #ifdef BOOST_HAS_ABI_HEADERS
57 # include BOOST_ABI_SUFFIX
58 #endif