2
0
mirror of https://github.com/boostorg/fiber.git synced 2026-02-19 02:12:24 +00:00

ioptimize test for fiber in spinlock

This commit is contained in:
Oliver Kowalke
2013-12-29 11:34:24 +01:00
parent cda3b09042
commit 19059fb1cd

View File

@@ -22,6 +22,7 @@ spinlock::spinlock() :
void
spinlock::lock()
{
bool is_fiber = 0 != scheduler::instance()->active().get();
for (;;)
{
// access to CPU's cache
@@ -30,7 +31,7 @@ spinlock::lock()
while ( LOCKED == state_)
{
// busy-wait
if ( scheduler::instance()->active() )
if ( is_fiber)
scheduler::instance()->yield();
else
this_thread::yield();