mirror of
https://github.com/boostorg/fiber.git
synced 2026-02-19 14:22:23 +00:00
use coroutines inside fiber
This commit is contained in:
@@ -20,19 +20,6 @@ namespace boost {
|
||||
namespace fibers {
|
||||
namespace detail {
|
||||
|
||||
fiber_base::fiber_base( fiber_context::ctx_fn fn,
|
||||
stack_context * stack_ctx,
|
||||
bool preserve_fpu) :
|
||||
fss_data_(),
|
||||
state_( READY),
|
||||
flags_( 0),
|
||||
priority_( 0),
|
||||
caller_(),
|
||||
callee_( fn, stack_ctx),
|
||||
except_(),
|
||||
waiting_()
|
||||
{ if ( preserve_fpu) flags_ |= flag_preserve_fpu; }
|
||||
|
||||
fiber_base::~fiber_base()
|
||||
{
|
||||
BOOST_ASSERT( is_terminated() );
|
||||
@@ -42,21 +29,22 @@ fiber_base::~fiber_base()
|
||||
void
|
||||
fiber_base::resume()
|
||||
{
|
||||
BOOST_ASSERT( is_running() );
|
||||
|
||||
caller_.jump( callee_, 0, preserve_fpu() );
|
||||
BOOST_ASSERT( caller_);
|
||||
BOOST_ASSERT( is_running() ); // set by the scheduler-algorithm
|
||||
|
||||
caller_();
|
||||
if ( has_exception() ) rethrow();
|
||||
}
|
||||
|
||||
void
|
||||
fiber_base::suspend()
|
||||
{
|
||||
callee_.jump( caller_, 0, preserve_fpu() );
|
||||
BOOST_ASSERT( callee_);
|
||||
BOOST_ASSERT( * callee_);
|
||||
|
||||
BOOST_ASSERT( is_running() );
|
||||
( * callee_)();
|
||||
|
||||
if ( unwind_requested() ) throw forced_unwind();
|
||||
BOOST_ASSERT( is_running() ); // set by the scheduler-algorithm
|
||||
}
|
||||
|
||||
void
|
||||
@@ -87,14 +75,6 @@ fiber_base::join( ptr_t const& p)
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
fiber_base::rethrow() const
|
||||
{
|
||||
BOOST_ASSERT( has_exception() );
|
||||
|
||||
rethrow_exception( except_);
|
||||
}
|
||||
|
||||
void *
|
||||
fiber_base::get_fss_data( void const* vp) const
|
||||
{
|
||||
@@ -133,6 +113,14 @@ fiber_base::set_fss_data(
|
||||
fss_data( data, cleanup_fn) ) );
|
||||
}
|
||||
|
||||
void
|
||||
fiber_base::rethrow() const
|
||||
{
|
||||
BOOST_ASSERT( has_exception() );
|
||||
|
||||
rethrow_exception( except_);
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
|
||||
Reference in New Issue
Block a user