Plasma Engine  2.0
Loading...
Searching...
No Matches
Semaphore.h
1#pragma once
2
3#include <Foundation/Basics.h>
4#include <Foundation/Threading/Implementation/ThreadingDeclarations.h>
5
16class PL_FOUNDATION_DLL plSemaphore
17{
18 PL_DISALLOW_COPY_AND_ASSIGN(plSemaphore);
19
20public:
23
29 plResult Create(plUInt32 uiInitialTokenCount = 0, plStringView sSharedName = plStringView());
30
34 plResult Open(plStringView sSharedName);
35
40 void AcquireToken();
41
45 void ReturnToken();
46
48 plResult TryAcquireToken(plTime timeout = plTime::MakeZero());
49
50private:
51 plSemaphoreHandle m_hSemaphore = {};
52};
A semaphore is used to synchronize threads, similar to a mutex (see plMutex).
Definition Semaphore.h:17
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12
PL_ALWAYS_INLINE static constexpr plTime MakeZero()
Creates an instance of plTime that was initialized with zero.
Definition Time.h:42