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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user