CpuYield Class Reference

#include <cpuyield.h>

Inheritance diagram for CpuYield:

Public Member Functions

 CpuYield (const void *res=nullptr)
 
 ~CpuYield ()
 
void Reset ()
 
void Pause ()
 

Static Public Member Functions

static void Wait (Int cnt)
 

Static Private Member Functions

static void _mm_pause ()
 

Additional Inherited Members

- Protected Types inherited from CpuYieldState
using SwitchDelegate = void(*)(CpuYieldState *state, const void *resource)
 
- Protected Attributes inherited from CpuYieldState
Int32 _count
 
Int32 _loopSize
 
const void * _resource
 
- Static Protected Attributes inherited from CpuYieldState
static const Int LOOPS_START_COUNT
 
static const Int LOOPS_MAX_GRANULARITY
 
static const Int LOOPS_BEFORE_YIELD
 
static const Int LOOPS_BEFORE_SLEEP
 
static const UInt LOCK_ACQUIRE
 
static const UInt LOCK_SPIN
 
static const UInt LOCK_RELEASE
 
static const UInt MAX_STATE_ENUM
 

Constructor & Destructor Documentation

◆ CpuYield()

CpuYield ( const void *  res = nullptr)
explicit
Parameters
[in]resThe contended resource because of which Pause might have to be called. Might be a nullptr (but shouldn't).

◆ ~CpuYield()

~CpuYield ( )

Member Function Documentation

◆ Reset()

void Reset ( void  )

◆ Pause()

void Pause ( )

Pauses a little while until the contended resource hopefully becomes available again. Depending on the number of calls this will either just do a light spin loop or it might put the thread to sleep. Furthermore offending threads might be logged to diagnose deadlocks or bad performance.

◆ Wait()

static void Wait ( Int  cnt)
static

◆ _mm_pause()

static void _mm_pause ( )
staticprivate