普通标志位(非原子)/ Non-atomic flag
More...
#include <flag.hpp>
|
|
| Plain ()=default |
| | 构造函数,默认未置位 / Constructor, default cleared
|
| |
| void | Set () noexcept |
| | 置位标志 / Set the flag
|
| |
| void | Clear () noexcept |
| | 清除标志 / Clear the flag
|
| |
| bool | IsSet () const noexcept |
| | 判断是否已置位 / Check whether the flag is set
|
| |
| bool | TestAndSet () noexcept |
| | 测试并置位:置位并返回旧状态 / Test-and-set: set and return previous state
|
| |
| bool | TestAndClear () noexcept |
| | 测试并清除:清除并返回旧状态 / Test-and-clear: clear and return previous state
|
| |
| bool | Exchange (bool set_value) noexcept |
| | 交换:写入指定值并返回旧状态 / Exchange: set to desired value and return previous state
|
| |
普通标志位(非原子)/ Non-atomic flag
不具备并发安全性;仅适用于单线程环境或外部已保证互斥/临界区保护的场景。 Not thread-safe; use only in single-threaded context or when externally synchronized.
Definition at line 114 of file flag.hpp.
◆ Clear()
| void LibXR::Flag::Plain::Clear |
( |
| ) |
|
|
inlinenoexcept |
清除标志 / Clear the flag
Definition at line 130 of file flag.hpp.
◆ Exchange()
| bool LibXR::Flag::Plain::Exchange |
( |
bool | set_value | ) |
|
|
inlinenodiscardnoexcept |
交换:写入指定值并返回旧状态 / Exchange: set to desired value and return previous state
- Parameters
-
| set_value | 期望写入的值 / Desired value to write |
- Returns
- true 旧值为 set / Old value was set
-
false 旧值为 clear / Old value was clear
Definition at line 174 of file flag.hpp.
175 {
176 bool old = value_;
177 value_ = set_value;
178 return old;
179 }
◆ IsSet()
| bool LibXR::Flag::Plain::IsSet |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
判断是否已置位 / Check whether the flag is set
- Returns
- true 已置位 / Flag is set
-
false 未置位 / Flag is clear
Definition at line 138 of file flag.hpp.
◆ Set()
| void LibXR::Flag::Plain::Set |
( |
| ) |
|
|
inlinenoexcept |
置位标志 / Set the flag
Definition at line 125 of file flag.hpp.
◆ TestAndClear()
| bool LibXR::Flag::Plain::TestAndClear |
( |
| ) |
|
|
inlinenodiscardnoexcept |
测试并清除:清除并返回旧状态 / Test-and-clear: clear and return previous state
- Returns
- true 先前已置位 / Was set
-
false 先前未置位 / Was clear
Definition at line 159 of file flag.hpp.
160 {
161 bool old = value_;
162 value_ = false;
163 return old;
164 }
◆ TestAndSet()
| bool LibXR::Flag::Plain::TestAndSet |
( |
| ) |
|
|
inlinenodiscardnoexcept |
测试并置位:置位并返回旧状态 / Test-and-set: set and return previous state
- Returns
- true 先前已置位 / Was already set
-
false 先前未置位 / Was clear
Definition at line 146 of file flag.hpp.
147 {
148 bool old = value_;
149 value_ = true;
150 return old;
151 }
The documentation for this class was generated from the following file: