Skip to content

Commit

Permalink
Work around missing std::this_thread::yield in gcc 4.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanieu committed Sep 15, 2015
1 parent c382886 commit dae7ec0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion include/async++/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,15 @@ class local_task {

// Now spin until the reference count drops to 1, since the scheduler
// may still have a reference to the task.
while (!internal_task.is_unique_ref(std::memory_order_acquire))
while (!internal_task.is_unique_ref(std::memory_order_acquire)) {
#if defined(__GLIBCXX__) && __GLIBCXX__ <= 20140612
// Some versions of libstdc++ (4.7 and below) don't include a
// definition of std::this_thread::yield().
sched_yield();
#else
std::this_thread::yield();
#endif
}
}

// Query whether the task has finished executing
Expand Down

0 comments on commit dae7ec0

Please sign in to comment.