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

add workstealing round_robin

This commit is contained in:
Oliver Kowalke
2013-10-25 18:01:56 +02:00
parent c19364b686
commit 436883ca33
10 changed files with 390 additions and 38 deletions

View File

@@ -86,7 +86,7 @@ round_robin::run()
if ( f->interruption_requested() )
f->set_ready();
if ( f->is_ready() )
rqueue_.push( f);
rqueue_.push_back( f);
else wqueue.push_back( s);
}
// exchange local with global waiting queue
@@ -97,7 +97,9 @@ round_robin::run()
detail::fiber_base::ptr_t f;
do
{
if ( ! rqueue_.try_pop( f) ) return false;
if ( rqueue_.empty() ) return false;
f.swap( rqueue_.front() );
rqueue_.pop_front();
if ( f->is_ready() ) break;
else BOOST_ASSERT_MSG( false, "fiber with invalid state in ready-queue");
}
@@ -210,22 +212,6 @@ round_robin::priority( detail::fiber_base::ptr_t const& f, int prio)
f->priority( prio);
}
fiber
round_robin::steal_from()
{
detail::fiber_base::ptr_t f;
if ( ! rqueue_.try_pop( f) ) return fiber();
return fiber( f);
}
void
round_robin::migrate_to( fiber const& f)
{
BOOST_ASSERT( f);
spawn( detail::scheduler::extract( f) );
}
}}
#ifdef BOOST_HAS_ABI_HEADERS