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

join only non-terminated fibers

- context::join() adds active-context to wait-queue only
  if joined context is not terminated
- we can not use terminated_is_linked() because the context
  might already be removed from scheudler's termianted-queue
This commit is contained in:
Oliver Kowalke
2015-09-16 22:11:11 +02:00
parent 70f4d9eeff
commit 00ae711cd7
2 changed files with 14 additions and 9 deletions

View File

@@ -44,6 +44,7 @@ context::active( context * active) noexcept {
void
context::set_terminated_() noexcept {
flags_ |= flag_terminated;
scheduler_->set_terminated( this);
}
@@ -127,14 +128,17 @@ context::release() noexcept {
void
context::join() noexcept {
// get active context
context * active_ctx = context::active();
// push active context to wait-queue, member
// of the context which has to be joined by
// the active context
wait_queue_.push_back( * active_ctx);
// suspend active context
scheduler_->re_schedule( active_ctx);
// wait for context which is not terminated
if ( 0 == ( flags_ & flag_terminated) ) {
// get active context
context * active_ctx = context::active();
// push active context to wait-queue, member
// of the context which has to be joined by
// the active context
wait_queue_.push_back( * active_ctx);
// suspend active context
scheduler_->re_schedule( active_ctx);
}
}
bool