|
MSTL 1.4.0
A Modern C++ Library with extended functionality, web components, and utility libraries
|
计数信号量类模板 更多...
#include <semaphore.hpp>
Public 成员函数 | |
| counting_semaphore (const platform_wait_t desired) noexcept | |
| 构造函数 | |
| ~counting_semaphore ()=default | |
| 析构函数 | |
| void | release (const platform_wait_t update=1) noexcept |
| 释放信号量 | |
| void | acquire () noexcept |
| 获取信号量 | |
| bool | try_acquire () noexcept |
| 尝试获取信号量 | |
| template<typename Rep, typename Period> | |
| bool | try_acquire_for (const duration< Rep, Period > &relative) noexcept |
| 在指定时间内尝试获取信号量 | |
| template<typename Clock, typename Dur> | |
| bool | try_acquire_until (const time_point< Clock, Dur > &timeout) noexcept |
| 在指定时间点前尝试获取信号量 | |
静态 Public 成员函数 | |
| static constexpr platform_wait_t | max () noexcept |
| 获取信号量的最大可能值 | |
计数信号量类模板
| LeastMaxValue | 信号量的最小最大值 |
计数信号量是一个轻量级的同步原语,用于控制对共享资源的访问。
LeastMaxValue指定了信号量计数器的最小最大值,实际值可以小于此值。 这个模板参数主要用于静态检查,确保信号量的合理使用。
在文件 semaphore.hpp 第 31 行定义.
|
inlineexplicitnoexcept |
|
inlinenoexcept |
|
inlinestaticconstexprnoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
在指定时间内尝试获取信号量
| Rep | 时间表示类型 |
| Period | 时间单位比例 |
| relative | 相对超时时间 |
阻塞当前线程,直到成功获取信号量或超时。
在文件 semaphore.hpp 第 126 行定义.
|
inlinenoexcept |
在指定时间点前尝试获取信号量
| Clock | 时钟类型 |
| Dur | 持续时间类型 |
| timeout | 绝对超时时间点 |
阻塞当前线程,直到成功获取信号量或到达指定时间点。
在文件 semaphore.hpp 第 143 行定义.