]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/context/src/execution_context.cpp
Add patch for failing prerm scripts
[ceph.git] / ceph / src / boost / libs / context / src / execution_context.cpp
CommitLineData
7c673cae
FG
1
2// Copyright Oliver Kowalke 2009.
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
11fdf7f2
TL
7#include "boost/context/detail/config.hpp"
8
9#if ! defined(BOOST_CONTEXT_NO_CXX11)
7c673cae 10
11fdf7f2 11#include "boost/context/execution_context.hpp"
7c673cae
FG
12#include <boost/config.hpp>
13
14#ifdef BOOST_HAS_ABI_HEADERS
15# include BOOST_ABI_PREFIX
16#endif
17
7c673cae
FG
18namespace boost {
19namespace context {
11fdf7f2
TL
20
21#if !defined(BOOST_NO_CXX11_THREAD_LOCAL)
22
7c673cae
FG
23namespace detail {
24
11fdf7f2
TL
25ecv1_activation_record::ptr_t &
26ecv1_activation_record::current() noexcept {
27 thread_local static ptr_t current;
28 return current;
29}
7c673cae
FG
30
31// zero-initialization
32thread_local static std::size_t counter;
33
34// schwarz counter
11fdf7f2 35ecv1_activation_record_initializer::ecv1_activation_record_initializer() noexcept {
7c673cae 36 if ( 0 == counter++) {
11fdf7f2 37 ecv1_activation_record::current().reset( new ecv1_activation_record() );
7c673cae
FG
38 }
39}
40
11fdf7f2 41ecv1_activation_record_initializer::~ecv1_activation_record_initializer() {
7c673cae 42 if ( 0 == --counter) {
11fdf7f2
TL
43 BOOST_ASSERT( ecv1_activation_record::current()->is_main_context() );
44 delete ecv1_activation_record::current().detach();
7c673cae
FG
45 }
46}
47
48}
49
11fdf7f2
TL
50namespace v1 {
51
7c673cae
FG
52execution_context
53execution_context::current() noexcept {
54 // initialized the first time control passes; per thread
11fdf7f2 55 thread_local static detail::ecv1_activation_record_initializer initializer;
7c673cae
FG
56 return execution_context();
57}
58
11fdf7f2
TL
59}
60
7c673cae
FG
61#endif
62
11fdf7f2
TL
63}}
64
b32b8144
FG
65#ifdef BOOST_HAS_ABI_HEADERS
66# include BOOST_ABI_SUFFIX
67#endif
11fdf7f2
TL
68
69#endif