|
header_utils
|
Helpers for multi-threaded code. More...
Concepts | |
| concept | ghassanpl::mutexlike |
| Anything that's lockable. | |
| concept | ghassanpl::timed_mutexlike |
| Any mutexlike that can also be attempted to be locked for some time. | |
| concept | ghassanpl::shared_mutexlike |
| RW mutex (read access can be shared, write access is exclusive). | |
Classes | |
| struct | ghassanpl::protected_object< T, MUTEX_TYPE > |
| A class that stores an object to which access is protected via a mutexlike; all operations are thread-safe unless specified otherwise. More... | |
Typedefs | |
| template<typename T, shared_mutexlike MUTEX_TYPE = std::shared_mutex> | |
| using | ghassanpl::shared_protected_object |
| Same as protected_object but uses std::shared_mutex by default. | |
Functions | |
| template<mutexlike MUTEX_TYPE, typename FUNC, typename... ARGS> | |
| auto | ghassanpl::under_protection (MUTEX_TYPE &m, FUNC &&func, ARGS &&... args) |
| Runs func under the protection of mutexlike m. | |
| template<shared_mutexlike MUTEX_TYPE, typename FUNC, typename... ARGS> | |
| auto | ghassanpl::under_read_protection (MUTEX_TYPE &m, FUNC &&func, ARGS &&... args) |
| Runs func under the read (shared) protection of mutexlike m. | |
| template<mutexlike MUTEX_TYPE, typename T> | |
| auto | ghassanpl::protected_copy (MUTEX_TYPE &m, T &&t) |
| Creates a copy of t under the protection of mutexlike m. | |
| template<mutexlike MUTEX_TYPE, typename T> | |
| auto | ghassanpl::protected_move (MUTEX_TYPE &m, T &&t) |
| Moves t under the protection of mutexlike m. | |
| template<mutexlike MUTEX_TYPE, typename T, typename U> | |
| auto | ghassanpl::protected_exchange (MUTEX_TYPE &m, T &t, U &&u) -> T |
| Exchanges t with u and returns the value of t, all under the protection of mutexlike m. | |
Helpers for multi-threaded code.
| using ghassanpl::shared_protected_object |
Same as protected_object but uses std::shared_mutex by default.
Definition at line 169 of file threading.h.
|
nodiscard |
Creates a copy of t under the protection of mutexlike m.
Definition at line 68 of file threading.h.
|
nodiscard |
Exchanges t with u and returns the value of t, all under the protection of mutexlike m.
Definition at line 85 of file threading.h.
|
nodiscard |
Moves t under the protection of mutexlike m.
Definition at line 77 of file threading.h.
| auto ghassanpl::under_protection | ( | MUTEX_TYPE & | m, |
| FUNC && | func, | ||
| ARGS &&... | args ) |
Runs func under the protection of mutexlike m.
Definition at line 46 of file threading.h.
| auto ghassanpl::under_read_protection | ( | MUTEX_TYPE & | m, |
| FUNC && | func, | ||
| ARGS &&... | args ) |
Runs func under the read (shared) protection of mutexlike m.
Definition at line 57 of file threading.h.