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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_Semaphore.h
Go to the documentation of this file.
1 /*
2 ,--. ,--. ,--. ,--.
3 ,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2024
4 '-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
5 | | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
6 `---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
7
8 Tracktion Engine uses a GPL/commercial licence - see LICENCE.md for details.
9*/
10
11#pragma once
12
13namespace moodycamel
14{
15 class LightweightSemaphore;
16 namespace details { class Semaphore; }
17}
18
19namespace tracktion { inline namespace graph
20{
21
22//==============================================================================
23//==============================================================================
28{
29public:
30 //==============================================================================
32 Semaphore (int initialCount = 0);
33
35 ~Semaphore();
36
42 bool wait();
43
49 bool try_wait();
50
57 bool timed_wait (std::uint64_t usecs);
58
62 void signal (int count = 1);
63
64private:
65 //==============================================================================
67
68 Semaphore(const Semaphore&) = delete;
69 Semaphore& operator= (const Semaphore& other) = delete;
70};
71
72
73//==============================================================================
74//==============================================================================
80{
81public:
82 //==============================================================================
84 LightweightSemaphore (int initialCount = 0);
85
88
94 bool wait();
95
101 bool try_wait();
102
109 bool timed_wait (std::uint64_t usecs);
110
114 void signal (int count = 1);
115
116private:
117 //==============================================================================
119
121 LightweightSemaphore& operator= (const LightweightSemaphore& other) = delete;
122};
123
124
125}} // namespace tracktion_engine
A counting semaphore that spins on a atomic before waiting so will avoid system calls if wait periods...
bool wait()
Decrements the count by one and if the result of this goes below zero the call will block.
bool timed_wait(std::uint64_t usecs)
Performs a wait operation.
bool try_wait()
Attemps to decrement the count by one.
void signal(int count=1)
Increases the count by the ammount specified.
A basic counting semaphore.
bool try_wait()
Attemps to decrement the count by one.
void signal(int count=1)
Increases the count by the ammount specified.
bool timed_wait(std::uint64_t usecs)
Performs a wait operation.
bool wait()
Decrements the count by one and if the result of this goes below zero the call will block.