apply std::allocator_arg as required by boost.context

This commit is contained in:
Oliver Kowalke 2015-09-26 20:23:04 +02:00
parent b5e475ff36
commit 4197d019f9
2 changed files with 134 additions and 132 deletions

View File

@ -8,6 +8,7 @@
#define BOOST_COROUTINES2_DETAIL_PULL_CONTROL_BLOCK_IPP
#include <exception>
#include <memory>
#include <boost/assert.hpp>
#include <boost/config.hpp>
@ -33,27 +34,27 @@ template< typename StackAllocator, typename Fn >
pull_coroutine< T >::control_block::control_block( context::preallocated palloc, StackAllocator salloc,
Fn && fn_, bool preserve_fpu_) :
other( nullptr),
ctx( palloc, salloc,
[=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void {
// create synthesized push_coroutine< T >
typename push_coroutine< T >::control_block synthesized_cb( this, ctx);
push_coroutine< T > synthesized( & synthesized_cb);
other = & synthesized_cb;
try {
// call coroutine-fn with synthesized push_coroutine as argument
fn( synthesized);
} catch ( forced_unwind const&) {
// do nothing for unwinding exception
} catch (...) {
// store other exceptions in exception-pointer
except = std::current_exception();
}
// set termination flags
state |= static_cast< int >( state_t::complete);
// jump back to ctx
other->ctx( preserve_fpu);
BOOST_ASSERT_MSG( false, "pull_coroutine is complete");
}),
ctx( std::allocator_arg, palloc, salloc,
[=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void {
// create synthesized push_coroutine< T >
typename push_coroutine< T >::control_block synthesized_cb( this, ctx);
push_coroutine< T > synthesized( & synthesized_cb);
other = & synthesized_cb;
try {
// call coroutine-fn with synthesized push_coroutine as argument
fn( synthesized);
} catch ( forced_unwind const&) {
// do nothing for unwinding exception
} catch (...) {
// store other exceptions in exception-pointer
except = std::current_exception();
}
// set termination flags
state |= static_cast< int >( state_t::complete);
// jump back to ctx
other->ctx( preserve_fpu);
BOOST_ASSERT_MSG( false, "pull_coroutine is complete");
}),
preserve_fpu( preserve_fpu_),
state( static_cast< int >( state_t::unwind) ),
except() {
@ -109,27 +110,27 @@ template< typename StackAllocator, typename Fn >
pull_coroutine< T & >::control_block::control_block( context::preallocated palloc, StackAllocator salloc,
Fn && fn_, bool preserve_fpu_) :
other( nullptr),
ctx( palloc, salloc,
[=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void {
// create synthesized push_coroutine< T >
typename push_coroutine< T & >::control_block synthesized_cb( this, ctx);
push_coroutine< T & > synthesized( & synthesized_cb);
other = & synthesized_cb;
try {
// call coroutine-fn with synthesized push_coroutine as argument
fn( synthesized);
} catch ( forced_unwind const&) {
// do nothing for unwinding exception
} catch (...) {
// store other exceptions in exception-pointer
except = std::current_exception();
}
// set termination flags
state |= static_cast< int >( state_t::complete);
// jump back to ctx
other->ctx( preserve_fpu);
BOOST_ASSERT_MSG( false, "pull_coroutine is complete");
}),
ctx( std::allocator_arg, palloc, salloc,
[=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void {
// create synthesized push_coroutine< T >
typename push_coroutine< T & >::control_block synthesized_cb( this, ctx);
push_coroutine< T & > synthesized( & synthesized_cb);
other = & synthesized_cb;
try {
// call coroutine-fn with synthesized push_coroutine as argument
fn( synthesized);
} catch ( forced_unwind const&) {
// do nothing for unwinding exception
} catch (...) {
// store other exceptions in exception-pointer
except = std::current_exception();
}
// set termination flags
state |= static_cast< int >( state_t::complete);
// jump back to ctx
other->ctx( preserve_fpu);
BOOST_ASSERT_MSG( false, "pull_coroutine is complete");
}),
preserve_fpu( preserve_fpu_),
state( static_cast< int >( state_t::unwind) ),
except() {
@ -184,27 +185,27 @@ template< typename StackAllocator, typename Fn >
pull_coroutine< void >::control_block::control_block( context::preallocated palloc, StackAllocator salloc,
Fn && fn_, bool preserve_fpu_) :
other( nullptr),
ctx( palloc, salloc,
[=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void {
// create synthesized push_coroutine< T >
typename push_coroutine< void >::control_block synthesized_cb( this, ctx);
push_coroutine< void > synthesized( & synthesized_cb);
other = & synthesized_cb;
try {
// call coroutine-fn with synthesized push_coroutine as argument
fn( synthesized);
} catch ( forced_unwind const&) {
// do nothing for unwinding exception
} catch (...) {
// store other exceptions in exception-pointer
except = std::current_exception();
}
// set termination flags
state |= static_cast< int >( state_t::complete);
// jump back to ctx
other->ctx( preserve_fpu);
BOOST_ASSERT_MSG( false, "pull_coroutine is complete");
}),
ctx( std::allocator_arg, palloc, salloc,
[=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void {
// create synthesized push_coroutine< T >
typename push_coroutine< void >::control_block synthesized_cb( this, ctx);
push_coroutine< void > synthesized( & synthesized_cb);
other = & synthesized_cb;
try {
// call coroutine-fn with synthesized push_coroutine as argument
fn( synthesized);
} catch ( forced_unwind const&) {
// do nothing for unwinding exception
} catch (...) {
// store other exceptions in exception-pointer
except = std::current_exception();
}
// set termination flags
state |= static_cast< int >( state_t::complete);
// jump back to ctx
other->ctx( preserve_fpu);
BOOST_ASSERT_MSG( false, "pull_coroutine is complete");
}),
preserve_fpu( preserve_fpu_),
state( static_cast< int >( state_t::unwind) ),
except() {

View File

@ -9,6 +9,7 @@
#include <algorithm>
#include <exception>
#include <memory>
#include <boost/assert.hpp>
#include <boost/config.hpp>
@ -34,29 +35,29 @@ template< typename StackAllocator, typename Fn >
push_coroutine< T >::control_block::control_block( context::preallocated palloc, StackAllocator salloc,
Fn && fn_, bool preserve_fpu_) :
other( nullptr),
ctx( palloc, salloc,
[=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void {
// create synthesized pull_coroutine< T >
typename pull_coroutine< T >::control_block synthesized_cb( this, ctx);
pull_coroutine< T > synthesized( & synthesized_cb);
other = & synthesized_cb;
// jump back to ctor
ctx( preserve_fpu);
try {
// call coroutine-fn with synthesized pull_coroutine as argument
fn( synthesized);
} catch ( forced_unwind const&) {
// do nothing for unwinding exception
} catch (...) {
// store other exceptions in exception-pointer
except = std::current_exception();
}
// set termination flags
state |= static_cast< int >( state_t::complete);
// jump back to ctx
other->ctx( preserve_fpu);
BOOST_ASSERT_MSG( false, "push_coroutine is complete");
}),
ctx( std::allocator_arg, palloc, salloc,
[=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void {
// create synthesized pull_coroutine< T >
typename pull_coroutine< T >::control_block synthesized_cb( this, ctx);
pull_coroutine< T > synthesized( & synthesized_cb);
other = & synthesized_cb;
// jump back to ctor
ctx( preserve_fpu);
try {
// call coroutine-fn with synthesized pull_coroutine as argument
fn( synthesized);
} catch ( forced_unwind const&) {
// do nothing for unwinding exception
} catch (...) {
// store other exceptions in exception-pointer
except = std::current_exception();
}
// set termination flags
state |= static_cast< int >( state_t::complete);
// jump back to ctx
other->ctx( preserve_fpu);
BOOST_ASSERT_MSG( false, "push_coroutine is complete");
}),
preserve_fpu( preserve_fpu_),
state( static_cast< int >( state_t::unwind) ),
except(),
@ -138,29 +139,29 @@ template< typename StackAllocator, typename Fn >
push_coroutine< T & >::control_block::control_block( context::preallocated palloc, StackAllocator salloc,
Fn && fn_, bool preserve_fpu_) :
other( nullptr),
ctx( palloc, salloc,
[=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void {
// create synthesized pull_coroutine< T >
typename pull_coroutine< T & >::control_block synthesized_cb( this, ctx);
pull_coroutine< T & > synthesized( & synthesized_cb);
other = & synthesized_cb;
// jump back to ctor
ctx( preserve_fpu);
try {
// call coroutine-fn with synthesized pull_coroutine as argument
fn( synthesized);
} catch ( forced_unwind const&) {
// do nothing for unwinding exception
} catch (...) {
// store other exceptions in exception-pointer
except = std::current_exception();
}
// set termination flags
state |= static_cast< int >( state_t::complete);
// jump back to ctx
other->ctx( preserve_fpu);
BOOST_ASSERT_MSG( false, "push_coroutine is complete");
}),
ctx( std::allocator_arg, palloc, salloc,
[=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void {
// create synthesized pull_coroutine< T >
typename pull_coroutine< T & >::control_block synthesized_cb( this, ctx);
pull_coroutine< T & > synthesized( & synthesized_cb);
other = & synthesized_cb;
// jump back to ctor
ctx( preserve_fpu);
try {
// call coroutine-fn with synthesized pull_coroutine as argument
fn( synthesized);
} catch ( forced_unwind const&) {
// do nothing for unwinding exception
} catch (...) {
// store other exceptions in exception-pointer
except = std::current_exception();
}
// set termination flags
state |= static_cast< int >( state_t::complete);
// jump back to ctx
other->ctx( preserve_fpu);
BOOST_ASSERT_MSG( false, "push_coroutine is complete");
}),
preserve_fpu( preserve_fpu_),
state( static_cast< int >( state_t::unwind) ),
except(),
@ -218,29 +219,29 @@ push_coroutine< T & >::control_block::valid() const noexcept {
template< typename StackAllocator, typename Fn >
push_coroutine< void >::control_block::control_block( context::preallocated palloc, StackAllocator salloc, Fn && fn_, bool preserve_fpu_) :
other( nullptr),
ctx( palloc, salloc,
[=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void {
// create synthesized pull_coroutine< T >
typename pull_coroutine< void >::control_block synthesized_cb( this, ctx);
pull_coroutine< void > synthesized( & synthesized_cb);
other = & synthesized_cb;
// jump back to ctor
ctx( preserve_fpu);
try {
// call coroutine-fn with synthesized pull_coroutine as argument
fn( synthesized);
} catch ( forced_unwind const&) {
// do nothing for unwinding exception
} catch (...) {
// store other exceptions in exception-pointer
except = std::current_exception();
}
// set termination flags
state |= static_cast< int >( state_t::complete);
// jump back to ctx
other->ctx( preserve_fpu);
BOOST_ASSERT_MSG( false, "push_coroutine is complete");
}),
ctx( std::allocator_arg, palloc, salloc,
[=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void {
// create synthesized pull_coroutine< T >
typename pull_coroutine< void >::control_block synthesized_cb( this, ctx);
pull_coroutine< void > synthesized( & synthesized_cb);
other = & synthesized_cb;
// jump back to ctor
ctx( preserve_fpu);
try {
// call coroutine-fn with synthesized pull_coroutine as argument
fn( synthesized);
} catch ( forced_unwind const&) {
// do nothing for unwinding exception
} catch (...) {
// store other exceptions in exception-pointer
except = std::current_exception();
}
// set termination flags
state |= static_cast< int >( state_t::complete);
// jump back to ctx
other->ctx( preserve_fpu);
BOOST_ASSERT_MSG( false, "push_coroutine is complete");
}),
preserve_fpu( preserve_fpu_),
state( static_cast< int >( state_t::unwind) ),
except() {