mirror of
https://github.com/boostorg/fiber.git
synced 2026-02-16 13:22:17 +00:00
store fiber-fn on fiber's stack
This commit is contained in:
@@ -166,7 +166,7 @@ private:
|
||||
boost::context::execution_context ctx_;
|
||||
|
||||
public:
|
||||
detail::worker_hook worker_hook_;
|
||||
detail::worker_hook worker_hook_;
|
||||
detail::terminated_hook terminated_hook_;
|
||||
detail::ready_hook ready_hook_;
|
||||
detail::remote_ready_hook remote_ready_hook_;
|
||||
@@ -265,10 +265,16 @@ public:
|
||||
ctx_( std::allocator_arg, palloc, salloc,
|
||||
// mutable: generated operator() is not const -> enables std::move( fn)
|
||||
// std::make_tuple: stores decayed copies of its args, implicitly unwraps std::reference_wrapper
|
||||
[=,fn=std::forward< Fn >( fn),tpl=std::make_tuple( std::forward< Args >( args) ...)] () mutable -> void {
|
||||
[=,fn_=std::forward< Fn >( fn),tpl=std::make_tuple( std::forward< Args >( args) ...),
|
||||
ctx=boost::context::execution_context::current()] () mutable -> void {
|
||||
try {
|
||||
// invoke fiber function
|
||||
boost::context::detail::invoke_helper( std::move( fn), std::move( tpl) );
|
||||
typename std::decay< Fn >::type fn( std::move( fn_) );
|
||||
// jump back after initialization
|
||||
ctx();
|
||||
// check for unwinding
|
||||
if ( ! unwinding_requested() ) {
|
||||
boost::context::detail::invoke_helper( fn, std::move( tpl) );
|
||||
}
|
||||
} catch ( fiber_interrupted const&) {
|
||||
} catch ( forced_unwind const&) {
|
||||
} catch ( ... ) {
|
||||
@@ -292,6 +298,8 @@ public:
|
||||
fss_data_(),
|
||||
wait_queue_(),
|
||||
splk_() {
|
||||
// switch for initialization
|
||||
ctx_();
|
||||
}
|
||||
|
||||
virtual ~context();
|
||||
|
||||
Reference in New Issue
Block a user