blob: 8424f9bc9833fb1f58e70e177a6e2984a1dbd0fe (
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
|
/* -------------------------------------------
Copyright SoftwareLabs
------------------------------------------- */
#pragma once
#include <NewKit/Defines.hpp>
#include <CompilerKit/CompilerKit.hxx>
namespace NewOS
{
class ProcessHeader;
typedef ProcessHeader* ProcessHeaderRef;
/// @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(ProcessHeader* process);
bool LockOrWait(ProcessHeader* process, const Int64& seconds);
public:
NEWOS_COPY_DEFAULT(Semaphore);
private:
ProcessHeaderRef fLockingProcess{nullptr};
};
} // namespace NewOS
|