tracktion-engine 3.0-10-g034fdde4aa5
Tracktion Engine — High level data model for audio applications

« « « Anklang Documentation
Loading...
Searching...
No Matches
Public Member Functions | List of all members
tracktion::graph::LightweightSemaphore Class Reference

A counting semaphore that spins on a atomic before waiting so will avoid system calls if wait periods are very short. More...

#include "tracktion_Semaphore.h"

Public Member Functions

 LightweightSemaphore (int initialCount=0)
 Creates a semaphore with an initial count.
 
 ~LightweightSemaphore ()
 Destructor.
 
bool wait ()
 Decrements the count by one and if the result of this goes below zero the call will block.
 
bool try_wait ()
 Attemps to decrement the count by one.
 
bool timed_wait (std::uint64_t usecs)
 Performs a wait operation.
 
void signal (int count=1)
 Increases the count by the ammount specified.
 

Detailed Description

A counting semaphore that spins on a atomic before waiting so will avoid system calls if wait periods are very short.

Definition at line 79 of file tracktion_Semaphore.h.

Constructor & Destructor Documentation

◆ LightweightSemaphore()

tracktion::graph::LightweightSemaphore::LightweightSemaphore ( int  initialCount = 0)

Creates a semaphore with an initial count.

Definition at line 53 of file tracktion_Semaphore.cpp.

◆ ~LightweightSemaphore()

tracktion::graph::LightweightSemaphore::~LightweightSemaphore ( )

Destructor.

Definition at line 58 of file tracktion_Semaphore.cpp.

Member Function Documentation

◆ signal()

void tracktion::graph::LightweightSemaphore::signal ( int  count = 1)

Increases the count by the ammount specified.

If the count goes above zero, this will signal waiting threads, unblocking them.

Definition at line 77 of file tracktion_Semaphore.cpp.

◆ timed_wait()

bool tracktion::graph::LightweightSemaphore::timed_wait ( std::uint64_t  usecs)

Performs a wait operation.

If the wait would actually block, the block happens for the given period of time before returning or the semaphore is signalled, whichever happens first.

Returns
true if the decrement actually happened or false if the count would have gone below zero and this had to block.

Definition at line 72 of file tracktion_Semaphore.cpp.

◆ try_wait()

bool tracktion::graph::LightweightSemaphore::try_wait ( )

Attemps to decrement the count by one.

If the decrement leaves the count above zero this will return true. If the decrement would leave the count below zero this will not block and return false.

Definition at line 67 of file tracktion_Semaphore.cpp.

◆ wait()

bool tracktion::graph::LightweightSemaphore::wait ( )

Decrements the count by one and if the result of this goes below zero the call will block.

Returns
true if the decrement actually happened or false if there was a problem (like the maximum count has been exceeded)

Definition at line 62 of file tracktion_Semaphore.cpp.


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