blob: 535598c75876441e60690486492c5634d7bf5a42 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
/*
* ========================================================
*
* HCore
* Copyright Mahrouss Logic, all rights reserved.
*
* ========================================================
*/
#pragma once
#include <NewKit/Defines.hpp>
#include <CompilerKit/CompilerKit.hpp>
namespace HCore
{
class Process;
typedef Process* ProcessPtr;
/// @brief Access control class, which locks a task until one is done.
class Semaphore final
{
public:
explicit Semaphore() = default;
~Semaphore() = default;
public:
bool IsLocked() const;
bool Unlock() noexcept;
public:
void Sync() noexcept;
public:
bool Lock(Process* process);
bool LockOrWait(Process* process, const Int64& seconds);
public:
HCORE_COPY_DEFAULT(Semaphore);
private:
ProcessPtr fLockingProcess{ nullptr };
};
}
|