https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33578
--- Comment #10 from Jonathan Wakely ---
For std::this_thread::yield() we do:
inline void
yield() noexcept
{
#if defined _GLIBCXX_HAS_GTHREADS && defined _GLIBCXX_USE_SCHED_YIELD
__gthread_yield();
#endif
}
And gthr-win32.h has:
__GTHREAD_WIN32_INLINE int
__gthread_yield (void)
{
Sleep (0);
return 0;
}
For atomics we also support using the x86 pause instruction
inline void
__thread_yield() noexcept
{
#if defined _GLIBCXX_HAS_GTHREADS && defined _GLIBCXX_USE_SCHED_YIELD
__gthread_yield();
#endif
}
inline void
__thread_relax() noexcept
{
#if defined __i386__ || defined __x86_64__
__builtin_ia32_pause();
#else
__thread_yield();
#endif
}
For Parallel Mode maybe we should just use __gthread_yield() everywhere?
gthr-win32.h already takes care of hiding the Win32 API. Since Parallel Mode is
likely to get removed at some point (now that we have the parallel STL algos
from C++17) I don't see any point in revisiting its implementation w.r.t using
of yield at all (comment 1).
tl;dr let's not reinvent the wheel when we already have portable code for
yielding, and don't want to redesign the parallel mode.