Sese Framework
2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
Semaphore.h
Go to the documentation of this file.
1
// Copyright 2024 libsese
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
19
20
#ifndef SESE_CORE_SEMAPHORE_H
21
#define SESE_CORE_SEMAPHORE_H
22
23
#include <
sese/Config.h
>
24
25
#include <chrono>
26
27
#ifndef SESE_PLATFORM_WINDOWS
28
#include <
semaphore.h
>
29
#endif
30
31
namespace
sese::system
{
32
34
class
Semaphore
final {
35
public
:
36
using
Ptr
= std::unique_ptr<Semaphore>;
37
42
static
Semaphore::Ptr
create
(std::string name, uint32_t initial_count = 1);
43
44
~Semaphore
();
45
47
bool
lock
();
48
50
bool
unlock
();
51
55
bool
tryLock
(std::chrono::milliseconds ms);
56
57
private
:
58
Semaphore
() =
default
;
59
60
#ifdef SESE_PLATFORM_WINDOWS
61
HANDLE hSemaphore{};
62
#else
63
std::string
sem_name
{};
64
sem_t *
semaphore
{};
65
#endif
66
};
67
68
}
69
70
#endif
//SESE_CORE_SEMAPHORE_H
71
sese
system
Semaphore.h
Generated on Tue Jan 7 2025 15:49:06 for Sese Framework by
1.11.0