mscorlib(4.0.0.0) API with additions
System.Threading.SpinWait Struct Reference

Provides support for spin-based waiting. More...

Public Member Functions

void SpinOnce ()
 Performs a single spin. More...
 
void Reset ()
 Resets the spin counter. More...
 

Static Public Member Functions

static void SpinUntil (Func< bool > condition)
 Spins until the specified condition is satisfied. More...
 
static bool SpinUntil (Func< bool > condition, TimeSpan timeout)
 Spins until the specified condition is satisfied or until the specified timeout is expired. More...
 
static bool SpinUntil (Func< bool > condition, int millisecondsTimeout)
 Spins until the specified condition is satisfied or until the specified timeout is expired. More...
 

Public Attributes

internal const int YIELD_THRESHOLD = 10
 
internal const int SLEEP_0_EVERY_HOW_MANY_TIMES = 5
 
internal const int SLEEP_1_EVERY_HOW_MANY_TIMES = 20
 

Properties

int Count [get]
 Gets the number of times M:System.Threading.SpinWait.SpinOnce has been called on this instance. More...
 
bool NextSpinWillYield [get]
 Gets whether the next call to M:System.Threading.SpinWait.SpinOnce will yield the processor, triggering a forced context switch. More...
 

Detailed Description

Provides support for spin-based waiting.

Definition at line 8 of file SpinWait.cs.

Member Function Documentation

◆ Reset()

void System.Threading.SpinWait.Reset ( )

Resets the spin counter.

Definition at line 76 of file SpinWait.cs.

◆ SpinOnce()

void System.Threading.SpinWait.SpinOnce ( )

Performs a single spin.

Definition at line 48 of file SpinWait.cs.

◆ SpinUntil() [1/3]

static void System.Threading.SpinWait.SpinUntil ( Func< bool >  condition)
static

Spins until the specified condition is satisfied.

Parameters
conditionA delegate to be executed over and over until it returns true.
Exceptions
T:System.ArgumentNullExceptionThe condition argument is null.

Definition at line 85 of file SpinWait.cs.

◆ SpinUntil() [2/3]

static bool System.Threading.SpinWait.SpinUntil ( Func< bool >  condition,
TimeSpan  timeout 
)
static

Spins until the specified condition is satisfied or until the specified timeout is expired.

Parameters
conditionA delegate to be executed over and over until it returns true.
timeoutA T:System.TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely.
Returns
True if the condition is satisfied within the timeout; otherwise, false
Exceptions
T:System.ArgumentNullExceptionThe condition argument is null.
T:System.ArgumentOutOfRangeExceptiontimeout is a negative number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than F:System.Int32.MaxValue.

Definition at line 98 of file SpinWait.cs.

◆ SpinUntil() [3/3]

static bool System.Threading.SpinWait.SpinUntil ( Func< bool >  condition,
int  millisecondsTimeout 
)
static

Spins until the specified condition is satisfied or until the specified timeout is expired.

Parameters
conditionA delegate to be executed over and over until it returns true.
millisecondsTimeoutThe number of milliseconds to wait, or F:System.Threading.Timeout.Infinite (-1) to wait indefinitely.
Returns
True if the condition is satisfied within the timeout; otherwise, false
Exceptions
T:System.ArgumentNullExceptionThe condition argument is null.
T:System.ArgumentOutOfRangeExceptionmillisecondsTimeout is a negative number other than -1, which represents an infinite time-out.

Definition at line 116 of file SpinWait.cs.

Property Documentation

◆ Count

int System.Threading.SpinWait.Count
get

Gets the number of times M:System.Threading.SpinWait.SpinOnce has been called on this instance.

Returns
Returns an integer that represents the number of times M:System.Threading.SpinWait.SpinOnce has been called on this instance.

Definition at line 22 of file SpinWait.cs.

◆ NextSpinWillYield

bool System.Threading.SpinWait.NextSpinWillYield
get

Gets whether the next call to M:System.Threading.SpinWait.SpinOnce will yield the processor, triggering a forced context switch.

Returns
Whether the next call to M:System.Threading.SpinWait.SpinOnce will yield the processor, triggering a forced context switch.

Definition at line 34 of file SpinWait.cs.


The documentation for this struct was generated from the following file: