Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7ac4be2

Browse files
authored
Fix spin_wait::spin_one() on Windows platforms
A conditional was accidentally inverted which meant that the spin-wait would first start yielding to the OS and then later start spinning with very large loopCount values, potentially leading to large pauses. Originally fixed by @loopunit in loopunit@242db2b
1 parent 99bb7f8 commit 7ac4be2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/spin_wait.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ namespace cppcoro
4444
{
4545
#if CPPCORO_OS_WINNT
4646
// Spin strategy taken from .NET System.SpinWait class.
47-
// I assume the Microsoft guys knew what they're doing.
48-
if (next_spin_will_yield())
47+
// I assume the Microsoft developers knew what they're doing.
48+
if (!next_spin_will_yield())
4949
{
5050
// CPU-level pause
5151
// Allow other hyper-threads to run while we busy-wait.

0 commit comments

Comments
 (0)