omni::graph::exec::unstable::AtomicBackoff

Defined in omni/graph/exec/unstable/AtomicBackoff.h

class AtomicBackoff

Exponential backoff pattern for waiting with a cap number of pauses.

This class implements exponential backoff, where each call to pause will cause busy waiting and increment the number of iterations for next pause call. All of this is cap with a maximum limit of pause calls after which waiting is considered long and switches to yield.

This class is useful when we expect short waits and would like to prevent yielding the compute resources for this short period of time.

This object is not ABI-safe.

Thread Safety

Methods are not thread safe unless otherwise noted.

Public Functions

inline constexpr AtomicBackoff() noexcept

Default constructor.

AtomicBackoff(const AtomicBackoff&) = delete
AtomicBackoff &operator=(const AtomicBackoff&) = delete
inline void pause() noexcept

Pause execution for a short period of time.

Use exponential backoff pattern and a upper wait cap to select between busy waiting and yielding.

Thread Safety

This method is not thread safe.

inline void reset() noexcept

Clear wait counter.

Thread Safety

This method is not thread safe.