PIP 5.6.1
Platform-Independent Primitives
Public Member Functions | List of all members
PISpinlock Class Reference

Lock based on atomic spinning for very short critical sections. More...

#include <pispinlock.h>

Public Member Functions

 PISpinlock ()
 Constructs unlocked spinlock.
 
 ~PISpinlock ()
 Destroy spinlock.
 
void lock ()
 Acquires the spinlock, busy-waiting until it becomes free.
 
void unlock ()
 Releases the spinlock.
 

Detailed Description

Lock based on atomic spinning for very short critical sections.

Fast and full-load lock.

PISpinlock provides critical code section defence between several threads. PISpinlock functionality similar to PIMutex, but working on atomic type and lock() method wait with 100% CPU core load.

For automatic lock-unlock use PISpinlockLocker.

Note

Use this type instead of PIMutex when less waiting time is more important than CPU load!