2
0
mirror of https://github.com/boostorg/fiber.git synced 2026-02-20 02:32:19 +00:00

execute func + set active fiber inside context::resume()

This commit is contained in:
Oliver Kowalke
2015-11-22 14:28:09 +01:00
parent a71e19ec4b
commit ca655a84d9
5 changed files with 11 additions and 63 deletions

View File

@@ -141,12 +141,6 @@ context::active() noexcept {
return active_;
}
void
context::active( context * active) noexcept {
BOOST_ASSERT( nullptr != active);
active_ = active;
}
void
context::reset_active() noexcept {
active_ = nullptr;
@@ -220,9 +214,16 @@ context::get_id() const noexcept {
return id( const_cast< context * >( this) );
}
std::function< void() > *
void
context::resume( std::function< void() > * func) {
return static_cast< std::function< void() > * >( ctx_( func) );
context * prev = this;
// active_ will point to `this`
// prev will point to previous active context
std::swap( active_, prev);
func = static_cast< std::function< void() > * >( ctx_( func) );
if ( nullptr != func) {
( * func)();
}
}
void