|
Boost : |
Subject: Re: [boost] Problems with yield_k workaround. Still too slow.
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2013-09-07 16:28:27
On 7 Sep 2013 at 10:59, Marcello Pietrobon wrote:
> The latest version, by Ion, using his spin_wait class solves completely the
> problem, at least in the cases I could test.
>
> An interesting note: Microsoft has introduced a function that completely
> solves the sleep(1) problem:
> http://msdn.microsoft.com/en-us/library/system.threading.thread.spinwait.aspx?cs-save-lang=1&cs-lang=cpp#code-snippet-1
>
> No comments on their decision to provide it only for their .net library and
> not for C++ as it seems to be.
It's very, very easy to roll your own in C++. Simply loop the PAUSE
x86 instruction (PAUSE = REP NOP, i.e. loop no-op). Hyperthreading
CPUs understand this means to go execute the other Hyperthread
instead.
Niall
-- Currently unemployed and looking for work. Work Portfolio: http://careers.stackoverflow.com/nialldouglas/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk