Sese Framework
x.y.z
A cross-platform framework
载入中...
搜索中...
未找到
Semaphore.h
浏览该文件的文档.
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
21
#ifndef SESE_CORE_SEMAPHORE_H
22
#define SESE_CORE_SEMAPHORE_H
23
24
25
#include <
sese/Config.h
>
26
27
#include <chrono>
28
29
30
#ifndef SESE_PLATFORM_WINDOWS
31
#include <
semaphore.h
>
32
#endif
33
34
namespace
sese::system
{
35
37
class
Semaphore
final {
38
public
:
39
using
Ptr
= std::unique_ptr<Semaphore>;
40
45
static
Semaphore::Ptr
create
(std::string name, uint32_t initial_count = 1);
46
47
~Semaphore
();
48
50
bool
lock
();
51
53
bool
unlock
();
54
58
bool
tryLock
(std::chrono::milliseconds ms);
59
60
private
:
61
Semaphore
() =
default
;
62
63
#ifdef SESE_PLATFORM_WINDOWS
64
HANDLE hSemaphore{};
65
#else
66
std::string
sem_name
{};
67
sem_t *
semaphore
{};
68
#endif
69
};
70
71
}
72
73
#endif
//SESE_CORE_SEMAPHORE_H
sese
system
Semaphore.h
生成于 2024年 十一月 4日 星期一 09:58:02 , 为 Sese Framework使用
1.11.0