Loading...
Searching...
No Matches
Lock

#include <Ultralight/Lock.h>

Overview

Tiny, efficient spinlock that is optimized for short locking periods but will still intelligently yield the current thread and save CPU if the lock is held longer.

Can be used in place of std::mutex since it implements the STL's Lockable interface.

Public Member Functions

constexpr Lock ()=default
 
UL_ALWAYS_INLINE void lock () noexcept
 
UL_ALWAYS_INLINE bool try_lock () noexcept
 
UL_ALWAYS_INLINE void unlock () noexcept
 

Protected Member Functions

 Lock (const Lock &)=delete
 
Lockoperator= (const Lock &)=delete
 
void contended_lock () noexcept
 

Protected Attributes

std::atomic< bool > lock_ = { 0 }
 

Constructor & Destructor Documentation

◆ Lock() [1/2]

Lock ( )
constexprdefault

◆ Lock() [2/2]

Lock ( const Lock & )
protecteddelete

Member Function Documentation

◆ contended_lock()

void contended_lock ( )
protectednoexcept

◆ lock()

UL_ALWAYS_INLINE void lock ( )
inlinenoexcept

◆ operator=()

Lock & operator= ( const Lock & )
protecteddelete

◆ try_lock()

UL_ALWAYS_INLINE bool try_lock ( )
inlinenoexcept

◆ unlock()

UL_ALWAYS_INLINE void unlock ( )
inlinenoexcept

Member Data Documentation

◆ lock_

std::atomic<bool> lock_ = { 0 }
protected

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