mirror of
https://github.com/boostorg/context.git
synced 2026-01-19 04:02:17 +00:00
@@ -21,20 +21,20 @@ namespace context {
|
||||
namespace detail {
|
||||
|
||||
// zero-initialization
|
||||
thread_local fiber_activation_record * current_rec;
|
||||
thread_local fiber_activation_record * fib_current_rec;
|
||||
thread_local static std::size_t counter;
|
||||
|
||||
// schwarz counter
|
||||
fiber_activation_record_initializer::fiber_activation_record_initializer() noexcept {
|
||||
if ( 0 == counter++) {
|
||||
current_rec = new fiber_activation_record();
|
||||
fib_current_rec = new fiber_activation_record();
|
||||
}
|
||||
}
|
||||
|
||||
fiber_activation_record_initializer::~fiber_activation_record_initializer() {
|
||||
if ( 0 == --counter) {
|
||||
BOOST_ASSERT( current_rec->is_main_context() );
|
||||
delete current_rec;
|
||||
BOOST_ASSERT( fib_current_rec->is_main_context() );
|
||||
delete fib_current_rec;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ fiber_activation_record *&
|
||||
fiber_activation_record::current() noexcept {
|
||||
// initialized the first time control passes; per thread
|
||||
thread_local static fiber_activation_record_initializer initializer;
|
||||
return current_rec;
|
||||
return fib_current_rec;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user