This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: std::this_thread::yield doesn't work
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Keith Erickson <kerickso at pppl dot gov>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Tue, 22 Oct 2013 13:33:23 +0100
- Subject: Re: std::this_thread::yield doesn't work
- Authentication-results: sourceware.org; auth=none
- References: <CA+PNwRN9YXKBnaSsuReB5Ki7Ef-oBHOUqgWDn4-U29Rv1cnx8g at mail dot gmail dot com>
On 20 October 2013 20:32, Keith Erickson wrote:
> Calling std::this_thread::yield on g++ 4.8.1 doesn't actually result
> in a call to the underlying pthread_yield or linux sched_yield. I
> eventually found this to be related to a define:
> _GLIBCXX_USE_SCHED_YIELD. How do I get that set, though? Is it
> something I can define inside my program, or do I really have to go
> and recompile the whole toolchain just to be able to use a basic
> concurrency function?
Technically you need to rebuild GCC (not the whole toolchain) with
--enable-libstdcxx-time, see
http://stackoverflow.com/a/12961816/981959 for more details.
You shouldn't define the macro in your program as it's an internal
detail of the library, but since it only affects header-only code not
anything compiled into the library, you can get away with defining it.
A cleaner alternative is suggested at
http://stackoverflow.com/a/9140270/981959