Implements a memory fenced ref count.
More...
#include <rc.hpp>
|
| thread_safe_refcount () noexcept |
| Construct a new thread safe refcount object.
|
|
void | operator++ () noexcept |
| Atomically increment the refcount by 1.
|
|
olong | operator-- () noexcept |
| Atomically decrement the internal counter by 1.
|
|
bool | inc_if_nonzero () noexcept |
| Atomically increments refcount by 1 if refcount is not 0, returns true if it incremented refcount.
|
|
olong | use_count () const noexcept |
| Returns the internal use count.
|
|
Implements a memory fenced ref count.
Definition at line 761 of file rc.hpp.
◆ thread_safe_refcount() [1/2]
openvpn::thread_safe_refcount::thread_safe_refcount |
( |
| ) |
|
|
inlinenoexcept |
Construct a new thread safe refcount object.
Definition at line 790 of file rc.hpp.
◆ thread_safe_refcount() [2/2]
◆ inc_if_nonzero()
bool openvpn::thread_safe_refcount::inc_if_nonzero |
( |
| ) |
|
|
inlinenoexcept |
Atomically increments refcount by 1 if refcount is not 0, returns true if it incremented refcount.
- Returns
- true if refcount was incremented
-
false if refcount was not incremented
If refcount is 0, do nothing and return false. If refcount != 0, increment it and return true.
Definition at line 820 of file rc.hpp.
◆ is_thread_safe()
constexpr bool openvpn::thread_safe_refcount::is_thread_safe |
( |
| ) |
|
|
inlinestaticconstexpr |
Returns true for this class.
- Returns
- true
This allows a uniform way to check at compile time or runtime and determine if the refcount type is thread safe or not. This one is thread safe.
Definition at line 847 of file rc.hpp.
◆ operator++()
void openvpn::thread_safe_refcount::operator++ |
( |
| ) |
|
|
inlinenoexcept |
Atomically increment the refcount by 1.
Definition at line 797 of file rc.hpp.
◆ operator--()
olong openvpn::thread_safe_refcount::operator-- |
( |
| ) |
|
|
inlinenoexcept |
Atomically decrement the internal counter by 1.
- Returns
- olong decremented ref count
Definition at line 805 of file rc.hpp.
◆ operator=()
◆ use_count()
olong openvpn::thread_safe_refcount::use_count |
( |
| ) |
const |
|
inlinenoexcept |
Returns the internal use count.
- Returns
- olong ref count
Definition at line 836 of file rc.hpp.
◆ rc
std::atomic<olong> openvpn::thread_safe_refcount::rc |
|
private |
The documentation for this class was generated from the following file: