4#ifndef GREM_CORE_SYSTEM_SYNCHRONIZATION_HPP
5#define GREM_CORE_SYSTEM_SYNCHRONIZATION_HPP
15#ifdef GREM_USE_MULTITHREADING
18#include <shared_mutex>
23#include <system_error>
32#ifdef GREM_USE_MULTITHREADING
33 RELAXED =
static_cast<int>(
static_cast<std::underlying_type_t<std::memory_order>
>(std::memory_order::relaxed)),
34 CONSUME =
static_cast<int>(
static_cast<std::underlying_type_t<std::memory_order>
>(std::memory_order::consume)),
35 ACQUIRE =
static_cast<int>(
static_cast<std::underlying_type_t<std::memory_order>
>(std::memory_order::acquire)),
36 RELEASE =
static_cast<int>(
static_cast<std::underlying_type_t<std::memory_order>
>(std::memory_order::release)),
37 ACQUIRE_RELEASE =
static_cast<int>(
static_cast<std::underlying_type_t<std::memory_order>
>(std::memory_order::acq_rel)),
38 SEQUENTIALLY_CONSISTENT =
static_cast<int>(
static_cast<std::underlying_type_t<std::memory_order>
>(std::memory_order::seq_cst)),
51#ifdef GREM_USE_MULTITHREADING
52[[nodiscard]]
constexpr std::memory_order translateMemoryOrder(
MemoryOrder order)
noexcept {
53 return static_cast<std::memory_order
>(
static_cast<std::underlying_type_t<std::memory_order>
>(
static_cast<int>(order)));
55#if __cpp_lib_atomic_ref < 201806L
56[[nodiscard]]
constexpr int translateMemoryOrderBuiltin(
MemoryOrder order)
noexcept {
76struct AtomicBase<
T*> {
77 using value_type =
T*;
78 using difference_type = ptrdiff_t;
82requires(std::is_integral_v<T> || std::is_floating_point_v<T>)
struct AtomicBase<T> {
84 using difference_type = value_type;
90class Atomic :
public detail::AtomicBase<T> {
92#ifdef GREM_USE_MULTITHREADING
98 constexpr Atomic() noexcept(std::is_nothrow_default_constructible_v<T>) = default;
109#ifdef GREM_USE_MULTITHREADING
110 return value.is_lock_free();
117#ifdef GREM_USE_MULTITHREADING
118 return value.is_lock_free();
125#ifdef GREM_USE_MULTITHREADING
126 value.store(newValue, detail::translateMemoryOrder(order));
134#ifdef GREM_USE_MULTITHREADING
135 value.store(newValue, detail::translateMemoryOrder(order));
143#ifdef GREM_USE_MULTITHREADING
144 return value.load(detail::translateMemoryOrder(order));
152#ifdef GREM_USE_MULTITHREADING
153 return value.load(detail::translateMemoryOrder(order));
161#ifdef GREM_USE_MULTITHREADING
162 return value.exchange(newValue, detail::translateMemoryOrder(order));
165 return std::exchange(value, newValue);
170#ifdef GREM_USE_MULTITHREADING
171 return value.exchange(newValue, detail::translateMemoryOrder(order));
174 return std::exchange(value, newValue);
179#ifdef GREM_USE_MULTITHREADING
180 return value.compare_exchange_weak(expected, desired, detail::translateMemoryOrder(success), detail::translateMemoryOrder(failure));
184 if (memcmp(&value, &expected,
sizeof(T)) == 0) {
194#ifdef GREM_USE_MULTITHREADING
195 return value.compare_exchange_weak(expected, desired, detail::translateMemoryOrder(success), detail::translateMemoryOrder(failure));
199 if (memcmp(&value, &expected,
sizeof(T)) == 0) {
209#ifdef GREM_USE_MULTITHREADING
210 return value.compare_exchange_weak(expected, desired, detail::translateMemoryOrder(order));
213 if (memcmp(&value, &expected,
sizeof(T)) == 0) {
223#ifdef GREM_USE_MULTITHREADING
224 return value.compare_exchange_weak(expected, desired, detail::translateMemoryOrder(order));
227 if (memcmp(&value, &expected,
sizeof(T)) == 0) {
237#ifdef GREM_USE_MULTITHREADING
238 return value.compare_exchange_strong(expected, desired, detail::translateMemoryOrder(success), detail::translateMemoryOrder(failure));
242 if (memcmp(&value, &expected,
sizeof(T)) == 0) {
252#ifdef GREM_USE_MULTITHREADING
253 return value.compare_exchange_strong(expected, desired, detail::translateMemoryOrder(success), detail::translateMemoryOrder(failure));
257 if (memcmp(&value, &expected,
sizeof(T)) == 0) {
267#ifdef GREM_USE_MULTITHREADING
268 return value.compare_exchange_strong(expected, desired, detail::translateMemoryOrder(order));
271 if (memcmp(&value, &expected,
sizeof(T)) == 0) {
281#ifdef GREM_USE_MULTITHREADING
282 return value.compare_exchange_strong(expected, desired, detail::translateMemoryOrder(order));
285 if (memcmp(&value, &expected,
sizeof(T)) == 0) {
295#ifdef GREM_USE_MULTITHREADING
296 value.wait(old, detail::translateMemoryOrder(order));
305#ifdef GREM_USE_MULTITHREADING
306 value.wait(old, detail::translateMemoryOrder(order));
315#ifdef GREM_USE_MULTITHREADING
321#ifdef GREM_USE_MULTITHREADING
327#ifdef GREM_USE_MULTITHREADING
333#ifdef GREM_USE_MULTITHREADING
339#ifdef GREM_USE_MULTITHREADING
340 return value.fetch_add(arg, detail::translateMemoryOrder(order));
351#ifdef GREM_USE_MULTITHREADING
352 return value.fetch_add(arg, detail::translateMemoryOrder(order));
362#ifdef GREM_USE_MULTITHREADING
363 return value.fetch_add(arg, detail::translateMemoryOrder(order));
373#ifdef GREM_USE_MULTITHREADING
374 return value.fetch_add(arg, detail::translateMemoryOrder(order));
384#ifdef GREM_USE_MULTITHREADING
385 return value.fetch_sub(arg, detail::translateMemoryOrder(order));
396#ifdef GREM_USE_MULTITHREADING
397 return value.fetch_sub(arg, detail::translateMemoryOrder(order));
407#ifdef GREM_USE_MULTITHREADING
408 return value.fetch_sub(arg, detail::translateMemoryOrder(order));
418#ifdef GREM_USE_MULTITHREADING
419 return value.fetch_sub(arg, detail::translateMemoryOrder(order));
429#ifdef GREM_USE_MULTITHREADING
430 return value.fetch_and(arg, detail::translateMemoryOrder(order));
440#ifdef GREM_USE_MULTITHREADING
441 return value.fetch_and(arg, detail::translateMemoryOrder(order));
451#ifdef GREM_USE_MULTITHREADING
452 return value.fetch_or(arg, detail::translateMemoryOrder(order));
462#ifdef GREM_USE_MULTITHREADING
463 return value.fetch_or(arg, detail::translateMemoryOrder(order));
473#ifdef GREM_USE_MULTITHREADING
474 return value.fetch_xor(arg, detail::translateMemoryOrder(order));
484#ifdef GREM_USE_MULTITHREADING
485 return value.fetch_xor(arg, detail::translateMemoryOrder(order));
495#ifdef GREM_USE_MULTITHREADING
496 std::atomic<T> value;
511#ifdef GREM_USE_MULTITHREADING
512 value.clear(detail::translateMemoryOrder(order));
520#ifdef GREM_USE_MULTITHREADING
521 return value.test_and_set(detail::translateMemoryOrder(order));
524 const bool old = value;
531#ifdef GREM_USE_MULTITHREADING
532 return value.test(detail::translateMemoryOrder(order));
540#ifdef GREM_USE_MULTITHREADING
541 value.wait(old, detail::translateMemoryOrder(order));
550#ifdef GREM_USE_MULTITHREADING
556#ifdef GREM_USE_MULTITHREADING
562#ifdef GREM_USE_MULTITHREADING
563 std::atomic_flag value{};
570#ifdef GREM_USE_MULTITHREADING
571 std::atomic_thread_fence(detail::translateMemoryOrder(order));
578#ifdef GREM_USE_MULTITHREADING
579 std::atomic_signal_fence(detail::translateMemoryOrder(order));
587#ifdef GREM_USE_MULTITHREADING
588 std::kill_dependency(y);
595class AtomicRef :
public detail::AtomicBase<std::remove_cv_t<T>> {
597 using typename detail::AtomicBase<std::remove_cv_t<T>>::value_type;
599#ifdef GREM_USE_MULTITHREADING
600#if __cpp_lib_atomic_ref >= 201806L
602 static constexpr std::size_t
required_alignment = std::atomic_ref<T>::required_alignment;
631 requires(!std::is_const_v<T>) {
639#ifdef GREM_USE_MULTITHREADING
640#if __cpp_lib_atomic_ref >= 201806L
641 return ref.is_lock_free();
651#ifdef GREM_USE_MULTITHREADING
652#if __cpp_lib_atomic_ref >= 201806L
653 ref.store(newValue, detail::translateMemoryOrder(order));
656 __atomic_store(ptr, &newValue, detail::translateMemoryOrderBuiltin(order));
666#ifdef GREM_USE_MULTITHREADING
667#if __cpp_lib_atomic_ref >= 201806L
668 return ref.load(detail::translateMemoryOrder(order));
672 __atomic_load(ptr, &result, detail::translateMemoryOrderBuiltin(order));
682#ifdef GREM_USE_MULTITHREADING
683#if __cpp_lib_atomic_ref >= 201806L
684 return ref.exchange(newValue, detail::translateMemoryOrder(order));
688 __atomic_exchange(ptr, &newValue, &result, detail::translateMemoryOrderBuiltin(order));
694 return std::exchange(*ptr, newValue);
699#ifdef GREM_USE_MULTITHREADING
700#if __cpp_lib_atomic_ref >= 201806L
701 return ref.compare_exchange_weak(expected, desired, detail::translateMemoryOrder(success), detail::translateMemoryOrder(failure));
704 return __atomic_compare_exchange(ptr, &expected, &desired,
true, detail::translateMemoryOrderBuiltin(success), detail::translateMemoryOrderBuiltin(failure));
710 if (memcmp(ptr, &expected,
sizeof(T)) == 0) {
720#ifdef GREM_USE_MULTITHREADING
721#if __cpp_lib_atomic_ref >= 201806L
722 return ref.compare_exchange_weak(expected, desired, detail::translateMemoryOrder(order));
725 return __atomic_compare_exchange(ptr, &expected, &desired,
true, detail::translateMemoryOrderBuiltin(order),
728 : detail::translateMemoryOrderBuiltin(order));
733 if (memcmp(ptr, &expected,
sizeof(T)) == 0) {
743#ifdef GREM_USE_MULTITHREADING
744#if __cpp_lib_atomic_ref >= 201806L
745 return ref.compare_exchange_strong(expected, desired, detail::translateMemoryOrder(success), detail::translateMemoryOrder(failure));
748 return __atomic_compare_exchange(ptr, &expected, &desired,
false, detail::translateMemoryOrderBuiltin(success), detail::translateMemoryOrderBuiltin(failure));
754 if (memcmp(ptr, &expected,
sizeof(T)) == 0) {
764#ifdef GREM_USE_MULTITHREADING
765#if __cpp_lib_atomic_ref >= 201806L
766 return ref.compare_exchange_strong(expected, desired, detail::translateMemoryOrder(order));
769 return __atomic_compare_exchange(ptr, &expected, &desired,
false, detail::translateMemoryOrderBuiltin(order),
772 : detail::translateMemoryOrderBuiltin(order));
777 if (memcmp(ptr, &expected,
sizeof(T)) == 0) {
787#ifdef GREM_USE_MULTITHREADING
788#if __cpp_lib_atomic_ref >= 201806L
789 ref.wait(old, detail::translateMemoryOrder(order));
791 while (
load(order) == old) {
803#ifdef GREM_USE_MULTITHREADING
804#if __cpp_lib_atomic_ref >= 201806L
811#ifdef GREM_USE_MULTITHREADING
812#if __cpp_lib_atomic_ref >= 201806L
819 requires(!std::is_const_v<T> && (std::is_integral_v<T> || std::is_floating_point_v<T>)) {
820#ifdef GREM_USE_MULTITHREADING
821#if __cpp_lib_atomic_ref >= 201806L
822 return ref.fetch_add(arg, detail::translateMemoryOrder(order));
825 return __atomic_fetch_add(ptr, arg, detail::translateMemoryOrderBuiltin(order));
837 requires(!std::is_const_v<T> && std::is_pointer_v<T>) {
838#ifdef GREM_USE_MULTITHREADING
839#if __cpp_lib_atomic_ref >= 201806L
840 return ref.fetch_add(arg, detail::translateMemoryOrder(order));
843 return __atomic_fetch_add(ptr, arg, detail::translateMemoryOrderBuiltin(order));
855 requires(!std::is_const_v<T> && (std::is_integral_v<T> || std::is_floating_point_v<T>)) {
856#ifdef GREM_USE_MULTITHREADING
857#if __cpp_lib_atomic_ref >= 201806L
858 return ref.fetch_sub(arg, detail::translateMemoryOrder(order));
861 return __atomic_fetch_sub(ptr, arg, detail::translateMemoryOrderBuiltin(order));
873 requires(!std::is_const_v<T> && std::is_pointer_v<T>) {
874#ifdef GREM_USE_MULTITHREADING
875#if __cpp_lib_atomic_ref >= 201806L
876 return ref.fetch_sub(arg, detail::translateMemoryOrder(order));
879 return __atomic_fetch_sub(ptr, arg, detail::translateMemoryOrderBuiltin(order));
891#ifdef GREM_USE_MULTITHREADING
892#if __cpp_lib_atomic_ref >= 201806L
893 return ref.fetch_and(arg, detail::translateMemoryOrder(order));
896 return __atomic_fetch_and(ptr, arg, detail::translateMemoryOrderBuiltin(order));
908#ifdef GREM_USE_MULTITHREADING
909#if __cpp_lib_atomic_ref >= 201806L
910 return ref.fetch_or(arg, detail::translateMemoryOrder(order));
913 return __atomic_fetch_or(ptr, arg, detail::translateMemoryOrderBuiltin(order));
925#ifdef GREM_USE_MULTITHREADING
926#if __cpp_lib_atomic_ref >= 201806L
927 return ref.fetch_xor(arg, detail::translateMemoryOrder(order));
930 return __atomic_fetch_xor(ptr, arg, detail::translateMemoryOrderBuiltin(order));
942#ifdef GREM_USE_MULTITHREADING
943#if __cpp_lib_atomic_ref >= 201806L
944 std::atomic_ref<T> ref;
955 constexpr Mutex() noexcept = default;
961#ifdef GREM_USE_MULTITHREADING
967#ifdef GREM_USE_MULTITHREADING
968 return mutex.try_lock();
975#ifdef GREM_USE_MULTITHREADING
981#ifdef GREM_USE_MULTITHREADING
994#ifdef GREM_USE_MULTITHREADING
1000#ifdef GREM_USE_MULTITHREADING
1001 return mutex.try_lock();
1008#ifdef GREM_USE_MULTITHREADING
1014#ifdef GREM_USE_MULTITHREADING
1015 std::recursive_mutex mutex{};
1027#ifdef GREM_USE_MULTITHREADING
1033#ifdef GREM_USE_MULTITHREADING
1034 return mutex.try_lock();
1041#ifdef GREM_USE_MULTITHREADING
1047#ifdef GREM_USE_MULTITHREADING
1048 mutex.lock_shared();
1053#ifdef GREM_USE_MULTITHREADING
1054 return mutex.try_lock_shared();
1061#ifdef GREM_USE_MULTITHREADING
1062 mutex.unlock_shared();
1067#ifdef GREM_USE_MULTITHREADING
1068 std::shared_mutex mutex{};
1080#ifdef GREM_USE_MULTITHREADING
1086#ifdef GREM_USE_MULTITHREADING
1087 return mutex.try_lock();
1093 template <
typename Rep,
typename Period>
1095#ifdef GREM_USE_MULTITHREADING
1096 return mutex.try_lock_for(timeoutDuration);
1098 (void)timeoutDuration;
1104#ifdef GREM_USE_MULTITHREADING
1105 return mutex.try_lock_until(timeoutTime);
1113#ifdef GREM_USE_MULTITHREADING
1119#ifdef GREM_USE_MULTITHREADING
1120 std::timed_mutex mutex{};
1132#ifdef GREM_USE_MULTITHREADING
1138#ifdef GREM_USE_MULTITHREADING
1139 return mutex.try_lock();
1145 template <
typename Rep,
typename Period>
1147#ifdef GREM_USE_MULTITHREADING
1148 return mutex.try_lock_for(timeoutDuration);
1150 (void)timeoutDuration;
1156#ifdef GREM_USE_MULTITHREADING
1157 return mutex.try_lock_until(timeoutTime);
1165#ifdef GREM_USE_MULTITHREADING
1171#ifdef GREM_USE_MULTITHREADING
1172 std::recursive_timed_mutex mutex{};
1184#ifdef GREM_USE_MULTITHREADING
1190#ifdef GREM_USE_MULTITHREADING
1191 return mutex.try_lock();
1197 template <
typename Rep,
typename Period>
1199#ifdef GREM_USE_MULTITHREADING
1200 return mutex.try_lock_for(timeoutDuration);
1202 (void)timeoutDuration;
1208#ifdef GREM_USE_MULTITHREADING
1209 return mutex.try_lock_until(timeoutTime);
1217#ifdef GREM_USE_MULTITHREADING
1223#ifdef GREM_USE_MULTITHREADING
1224 mutex.lock_shared();
1229#ifdef GREM_USE_MULTITHREADING
1230 return mutex.try_lock_shared();
1236 template <
typename Rep,
typename Period>
1238#ifdef GREM_USE_MULTITHREADING
1239 return mutex.try_lock_shared_for(timeoutDuration);
1241 (void)timeoutDuration;
1247#ifdef GREM_USE_MULTITHREADING
1248 return mutex.try_lock_shared_until(timeoutTime);
1256#ifdef GREM_USE_MULTITHREADING
1257 mutex.unlock_shared();
1262#ifdef GREM_USE_MULTITHREADING
1263 std::shared_timed_mutex mutex{};
1267template <
typename Lockable1,
typename Lockable2,
typename... LockableN>
1269#ifdef GREM_USE_MULTITHREADING
1270 std::lock(lock1, lock2, lockN...);
1272 bool locked[2 +
sizeof...(LockableN)]{};
1279 ((lockN.lock(), (locked[i++] =
true)), ...);
1288 ((locked[i++] && (lockN.unlock(),
false)), ...);
1309template <
typename... MutexTypes>
1312#ifdef GREM_USE_MULTITHREADING
1314 : implementation(mutexes...) {}
1317 : implementation(std::adopt_lock, mutexes...) {}
1320 : mutexes(mutexes...) {
1325 : mutexes(mutexes...) {}
1328 [&]<std::size_t... Indices>(std::index_sequence<Indices...>) {
1330 }(std::make_index_sequence<
sizeof...(MutexTypes)>{});
1338#ifdef GREM_USE_MULTITHREADING
1339 std::scoped_lock<MutexTypes...> implementation;
1341 Tuple<MutexTypes&...> mutexes;
1345template <
typename MutexType>
1350#ifdef GREM_USE_MULTITHREADING
1352 : implementation(mutex) {}
1355 : implementation(std::adopt_lock, mutex) {}
1374#ifdef GREM_USE_MULTITHREADING
1375 std::scoped_lock<MutexType> implementation;
1381template <
typename MutexType>
1389#ifdef GREM_USE_MULTITHREADING
1393 : implementation(
mutex) {}
1396 : implementation(
mutex, std::defer_lock) {}
1399 : implementation(
mutex, std::try_to_lock) {}
1402 : implementation(
mutex, std::adopt_lock) {}
1404 template <
typename Rep,
typename Period>
1406 : implementation(
mutex, timeoutDuration) {}
1409 : implementation(
mutex, timeoutTime) {}
1414 : associatedMutex(std::exchange(other.associatedMutex,
nullptr))
1415 , locked(std::exchange(other.locked,
false)) {}
1418 : associatedMutex(&
mutex) {
1424 : associatedMutex(&
mutex) {}
1427 : associatedMutex(&
mutex) {
1428 if constexpr (
requires {
mutex.try_lock(); }) {
1429 locked =
mutex.try_lock();
1434 : associatedMutex(&
mutex)
1437 template <
typename Rep,
typename Period>
1439 : associatedMutex(&
mutex) {
1440 if constexpr (
requires {
mutex.try_lock_for(timeoutDuration); }) {
1441 locked =
mutex.try_lock_for(timeoutDuration);
1442 }
else if constexpr (
requires {
mutex.try_lock(); }) {
1443 locked =
mutex.try_lock();
1448 : associatedMutex(&
mutex) {
1449 if constexpr (
requires {
mutex.try_lock_until(timeoutTime); }) {
1450 locked =
mutex.try_lock_until(timeoutTime);
1451 }
else if constexpr (
requires {
mutex.try_lock(); }) {
1452 locked =
mutex.try_lock();
1458 associatedMutex->unlock();
1463 if (
this == &other) {
1466 associatedMutex = std::exchange(other.associatedMutex,
nullptr);
1467 locked = std::exchange(other.locked,
false);
1475#ifdef GREM_USE_MULTITHREADING
1476 implementation.lock();
1478 if (!associatedMutex) {
1479 throw std::system_error{make_error_code(std::errc::operation_not_permitted)};
1482 throw std::system_error{make_error_code(std::errc::resource_deadlock_would_occur)};
1484 associatedMutex->lock();
1489#ifdef GREM_USE_MULTITHREADING
1491 return implementation.try_lock();
1494 template <
typename Rep,
typename Period>
1496 requires(
requires(std::unique_lock<MutexType> l) { l.try_lock_for(timeoutDuration); }) {
1497 return implementation.try_lock_for(timeoutDuration);
1501 return implementation.try_lock_until(timeoutTime);
1505 if (!associatedMutex) {
1506 throw std::system_error{make_error_code(std::errc::operation_not_permitted)};
1509 throw std::system_error{
make_error_code(std::errc::resource_deadlock_would_occur)};
1511 return locked = associatedMutex->try_lock();
1514 template <
typename Rep,
typename Period>
1516 if (!associatedMutex) {
1517 throw std::system_error{make_error_code(std::errc::operation_not_permitted)};
1520 throw std::system_error{
make_error_code(std::errc::resource_deadlock_would_occur)};
1522 return locked = associatedMutex->try_lock_for(timeoutDuration);
1526 if (!associatedMutex) {
1527 throw std::system_error{make_error_code(std::errc::operation_not_permitted)};
1530 throw std::system_error{
make_error_code(std::errc::resource_deadlock_would_occur)};
1532 return locked = associatedMutex->try_lock_until(timeoutTime);
1537#ifdef GREM_USE_MULTITHREADING
1538 implementation.unlock();
1540 if (!associatedMutex || !locked) {
1541 throw std::system_error{make_error_code(std::errc::operation_not_permitted)};
1543 associatedMutex->unlock();
1549#ifdef GREM_USE_MULTITHREADING
1550 implementation.swap(other.implementation);
1552 std::swap(associatedMutex, other.associatedMutex);
1553 std::swap(locked, other.locked);
1562#ifdef GREM_USE_MULTITHREADING
1563 return implementation.release();
1566 return std::exchange(associatedMutex,
nullptr);
1571#ifdef GREM_USE_MULTITHREADING
1572 return implementation.mutex();
1574 return associatedMutex;
1579#ifdef GREM_USE_MULTITHREADING
1580 return implementation.owns_lock();
1582 return associatedMutex && locked;
1587#ifdef GREM_USE_MULTITHREADING
1588 return static_cast<bool>(implementation);
1595#ifdef GREM_USE_MULTITHREADING
1596 std::unique_lock<MutexType> implementation;
1599 bool locked =
false;
1603template <
typename MutexType>
1611#ifdef GREM_USE_MULTITHREADING
1615 : implementation(
mutex) {}
1618 : implementation(
mutex, std::defer_lock) {}
1621 : implementation(
mutex, std::try_to_lock) {}
1624 : implementation(
mutex, std::adopt_lock) {}
1626 template <
typename Rep,
typename Period>
1628 : implementation(
mutex, timeoutDuration) {}
1631 : implementation(
mutex, timeoutTime) {}
1636 : associatedMutex(std::exchange(other.associatedMutex,
nullptr))
1637 , locked(std::exchange(other.locked,
false)) {}
1640 : associatedMutex(&
mutex) {
1641 mutex.lock_shared();
1646 : associatedMutex(&
mutex) {}
1649 : associatedMutex(&
mutex) {
1650 if constexpr (
requires {
mutex.try_lock_shared(); }) {
1651 locked =
mutex.try_lock_shared();
1656 : associatedMutex(&
mutex)
1659 template <
typename Rep,
typename Period>
1661 : associatedMutex(&
mutex) {
1662 if constexpr (
requires {
mutex.try_lock_shared_for(timeoutDuration); }) {
1663 locked =
mutex.try_lock_shared_for(timeoutDuration);
1664 }
else if constexpr (
requires {
mutex.try_lock_shared(); }) {
1665 locked =
mutex.try_lock_shared();
1670 : associatedMutex(&
mutex) {
1671 if constexpr (
requires {
mutex.try_lock_shared_until(timeoutTime); }) {
1672 locked =
mutex.try_lock_shared_until(timeoutTime);
1673 }
else if constexpr (
requires {
mutex.try_lock_shared(); }) {
1674 locked =
mutex.try_lock_shared();
1680 associatedMutex->unlock_shared();
1685 if (
this == &other) {
1688 associatedMutex = std::exchange(other.associatedMutex,
nullptr);
1689 locked = std::exchange(other.locked,
false);
1697#ifdef GREM_USE_MULTITHREADING
1698 implementation.lock();
1700 if (!associatedMutex) {
1701 throw std::system_error{make_error_code(std::errc::operation_not_permitted)};
1704 throw std::system_error{make_error_code(std::errc::resource_deadlock_would_occur)};
1706 associatedMutex->lock_shared();
1711#ifdef GREM_USE_MULTITHREADING
1713 return implementation.try_lock();
1716 template <
typename Rep,
typename Period>
1718 requires(
requires(std::shared_lock<MutexType> l) { l.try_lock_for(timeoutDuration); }) {
1719 return implementation.try_lock_for(timeoutDuration);
1723 return implementation.try_lock_until(timeoutTime);
1727 if (!associatedMutex) {
1728 throw std::system_error{make_error_code(std::errc::operation_not_permitted)};
1731 throw std::system_error{
make_error_code(std::errc::resource_deadlock_would_occur)};
1733 return locked = associatedMutex->try_lock_shared();
1736 template <
typename Rep,
typename Period>
1738 requires(
requires(
mutex_type m) { m.try_lock_shared_for(timeoutDuration); }) {
1739 if (!associatedMutex) {
1740 throw std::system_error{make_error_code(std::errc::operation_not_permitted)};
1743 throw std::system_error{
make_error_code(std::errc::resource_deadlock_would_occur)};
1745 return locked = associatedMutex->try_lock_shared_for(timeoutDuration);
1749 if (!associatedMutex) {
1750 throw std::system_error{make_error_code(std::errc::operation_not_permitted)};
1753 throw std::system_error{
make_error_code(std::errc::resource_deadlock_would_occur)};
1755 return locked = associatedMutex->try_lock_shared_until(timeoutTime);
1760#ifdef GREM_USE_MULTITHREADING
1761 implementation.unlock();
1763 if (!associatedMutex || !locked) {
1764 throw std::system_error{make_error_code(std::errc::operation_not_permitted)};
1766 associatedMutex->unlock_shared();
1772#ifdef GREM_USE_MULTITHREADING
1773 implementation.swap(other.implementation);
1775 std::swap(associatedMutex, other.associatedMutex);
1776 std::swap(locked, other.locked);
1785#ifdef GREM_USE_MULTITHREADING
1786 return implementation.release();
1789 return std::exchange(associatedMutex,
nullptr);
1794#ifdef GREM_USE_MULTITHREADING
1795 return implementation.mutex();
1797 return associatedMutex;
1802#ifdef GREM_USE_MULTITHREADING
1803 return implementation.owns_lock();
1805 return associatedMutex && locked;
1810#ifdef GREM_USE_MULTITHREADING
1811 return static_cast<bool>(implementation);
1818#ifdef GREM_USE_MULTITHREADING
1819 std::shared_lock<MutexType> implementation;
1822 bool locked =
false;
#define GREM_ASSERT(expression)
Definition assertions.hpp:77
#define GREM_ALWAYS_INLINE
Definition attributes.hpp:10
GREM_ALWAYS_INLINE void notify_one() noexcept
Definition synchronization.hpp:549
GREM_ALWAYS_INLINE void notify_all() noexcept
Definition synchronization.hpp:555
constexpr AtomicFlag() noexcept=default
GREM_ALWAYS_INLINE void wait(bool old, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) const noexcept
Definition synchronization.hpp:539
GREM_ALWAYS_INLINE bool test(MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) const noexcept
Definition synchronization.hpp:530
GREM_ALWAYS_INLINE void clear(MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) noexcept
Definition synchronization.hpp:510
GREM_ALWAYS_INLINE bool test_and_set(MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) noexcept
Definition synchronization.hpp:519
GREM_ALWAYS_INLINE value_type operator=(value_type desired) const noexcept
Definition synchronization.hpp:630
static constexpr std::size_t required_alignment
Definition synchronization.hpp:621
GREM_ALWAYS_INLINE T fetch_sub(std::ptrdiff_t arg, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) const noexcept
Definition synchronization.hpp:872
GREM_ALWAYS_INLINE T fetch_add(std::ptrdiff_t arg, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) const noexcept
Definition synchronization.hpp:836
GREM_ALWAYS_INLINE void wait(T old, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) const noexcept
Definition synchronization.hpp:786
GREM_ALWAYS_INLINE bool compare_exchange_weak(T &expected, T desired, MemoryOrder success, MemoryOrder failure) const noexcept
Definition synchronization.hpp:698
GREM_ALWAYS_INLINE T fetch_and(T arg, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) const noexcept
Definition synchronization.hpp:890
GREM_ALWAYS_INLINE T exchange(T newValue, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) const noexcept
Definition synchronization.hpp:681
GREM_ALWAYS_INLINE AtomicRef(T &obj)
Definition synchronization.hpp:623
GREM_ALWAYS_INLINE T fetch_add(T arg, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) const noexcept
Definition synchronization.hpp:818
GREM_ALWAYS_INLINE T fetch_xor(T arg, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) const noexcept
Definition synchronization.hpp:924
GREM_ALWAYS_INLINE T fetch_sub(T arg, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) const noexcept
Definition synchronization.hpp:854
GREM_ALWAYS_INLINE void notify_all() noexcept
Definition synchronization.hpp:810
GREM_ALWAYS_INLINE void notify_one() noexcept
Definition synchronization.hpp:802
GREM_ALWAYS_INLINE bool is_lock_free() const noexcept
Definition synchronization.hpp:638
GREM_ALWAYS_INLINE void store(T newValue, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) const noexcept
Definition synchronization.hpp:650
GREM_ALWAYS_INLINE bool compare_exchange_strong(T &expected, T desired, MemoryOrder success, MemoryOrder failure) const noexcept
Definition synchronization.hpp:742
GREM_ALWAYS_INLINE bool compare_exchange_strong(T &expected, T desired, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) const noexcept
Definition synchronization.hpp:763
static constexpr bool is_always_lock_free
Definition synchronization.hpp:620
AtomicRef & operator=(const AtomicRef &)=delete
GREM_ALWAYS_INLINE bool compare_exchange_weak(T &expected, T desired, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) const noexcept
Definition synchronization.hpp:719
GREM_ALWAYS_INLINE T fetch_or(T arg, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) const noexcept
Definition synchronization.hpp:907
GREM_ALWAYS_INLINE T load(MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) const noexcept
Definition synchronization.hpp:665
GREM_ALWAYS_INLINE AtomicRef(const AtomicRef &other) noexcept
Definition synchronization.hpp:626
GREM_ALWAYS_INLINE bool compare_exchange_strong(T &expected, T desired, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) noexcept
Definition synchronization.hpp:266
GREM_ALWAYS_INLINE void notify_one() volatile noexcept
Definition synchronization.hpp:320
Atomic(const Atomic &)=delete
GREM_ALWAYS_INLINE T fetch_or(T arg, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) volatile noexcept
Definition synchronization.hpp:461
Atomic & operator=(const Atomic &)=delete
Atomic & operator=(const Atomic &) volatile =delete
GREM_ALWAYS_INLINE T load(MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) const noexcept
Definition synchronization.hpp:142
GREM_ALWAYS_INLINE T fetch_add(T arg, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) volatile noexcept
Definition synchronization.hpp:349
GREM_ALWAYS_INLINE T fetch_sub(std::ptrdiff_t arg, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) volatile noexcept
Definition synchronization.hpp:417
GREM_ALWAYS_INLINE bool compare_exchange_strong(T &expected, T desired, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) volatile noexcept
Definition synchronization.hpp:280
GREM_ALWAYS_INLINE void store(T newValue, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) volatile noexcept
Definition synchronization.hpp:133
GREM_ALWAYS_INLINE void store(T newValue, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) noexcept
Definition synchronization.hpp:124
GREM_ALWAYS_INLINE void notify_one() noexcept
Definition synchronization.hpp:314
GREM_ALWAYS_INLINE T fetch_xor(T arg, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) noexcept
Definition synchronization.hpp:472
GREM_ALWAYS_INLINE bool compare_exchange_strong(T &expected, T desired, MemoryOrder success, MemoryOrder failure) volatile noexcept
Definition synchronization.hpp:251
GREM_ALWAYS_INLINE bool is_lock_free() const noexcept
Definition synchronization.hpp:108
GREM_ALWAYS_INLINE T fetch_and(T arg, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) volatile noexcept
Definition synchronization.hpp:439
GREM_ALWAYS_INLINE void notify_all() noexcept
Definition synchronization.hpp:326
constexpr Atomic() noexcept(std::is_nothrow_default_constructible_v< T >)=default
GREM_ALWAYS_INLINE bool compare_exchange_strong(T &expected, T desired, MemoryOrder success, MemoryOrder failure) noexcept
Definition synchronization.hpp:236
GREM_ALWAYS_INLINE T fetch_add(std::ptrdiff_t arg, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) volatile noexcept
Definition synchronization.hpp:372
GREM_ALWAYS_INLINE bool compare_exchange_weak(T &expected, T desired, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) noexcept
Definition synchronization.hpp:208
GREM_ALWAYS_INLINE bool is_lock_free() const volatile noexcept
Definition synchronization.hpp:116
GREM_ALWAYS_INLINE T exchange(T newValue, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) noexcept
Definition synchronization.hpp:160
GREM_ALWAYS_INLINE void wait(T old, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) const volatile noexcept
Definition synchronization.hpp:304
GREM_ALWAYS_INLINE T fetch_sub(T arg, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) volatile noexcept
Definition synchronization.hpp:394
GREM_ALWAYS_INLINE T fetch_or(T arg, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) noexcept
Definition synchronization.hpp:450
GREM_ALWAYS_INLINE T fetch_and(T arg, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) noexcept
Definition synchronization.hpp:428
GREM_ALWAYS_INLINE T fetch_sub(T arg, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) noexcept
Definition synchronization.hpp:383
GREM_ALWAYS_INLINE bool compare_exchange_weak(T &expected, T desired, MemoryOrder success, MemoryOrder failure) noexcept
Definition synchronization.hpp:178
GREM_ALWAYS_INLINE void notify_all() volatile noexcept
Definition synchronization.hpp:332
GREM_ALWAYS_INLINE T fetch_xor(T arg, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) volatile noexcept
Definition synchronization.hpp:483
GREM_ALWAYS_INLINE bool compare_exchange_weak(T &expected, T desired, MemoryOrder success, MemoryOrder failure) volatile noexcept
Definition synchronization.hpp:193
static constexpr bool is_always_lock_free
Definition synchronization.hpp:95
GREM_ALWAYS_INLINE bool compare_exchange_weak(T &expected, T desired, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) volatile noexcept
Definition synchronization.hpp:222
GREM_ALWAYS_INLINE T load(MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) const volatile noexcept
Definition synchronization.hpp:151
GREM_ALWAYS_INLINE T fetch_add(std::ptrdiff_t arg, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) noexcept
Definition synchronization.hpp:361
GREM_ALWAYS_INLINE T fetch_sub(std::ptrdiff_t arg, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) noexcept
Definition synchronization.hpp:406
GREM_ALWAYS_INLINE T exchange(T newValue, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) volatile noexcept
Definition synchronization.hpp:169
GREM_ALWAYS_INLINE void wait(T old, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) const noexcept
Definition synchronization.hpp:294
GREM_ALWAYS_INLINE T fetch_add(T arg, MemoryOrder order=MemoryOrder::SEQUENTIALLY_CONSISTENT) noexcept
Definition synchronization.hpp:338
GREM_ALWAYS_INLINE bool try_lock()
Definition synchronization.hpp:966
GREM_ALWAYS_INLINE void unlock()
Definition synchronization.hpp:974
constexpr Mutex() noexcept=default
GREM_ALWAYS_INLINE void lock()
Definition synchronization.hpp:960
GREM_ALWAYS_INLINE void unlock()
Definition synchronization.hpp:1007
constexpr RecursiveMutex() noexcept=default
GREM_ALWAYS_INLINE bool try_lock()
Definition synchronization.hpp:999
GREM_ALWAYS_INLINE void lock()
Definition synchronization.hpp:993
GREM_ALWAYS_INLINE void unlock()
Definition synchronization.hpp:1164
GREM_ALWAYS_INLINE bool try_lock_until(const TimePoint &timeoutTime)
Definition synchronization.hpp:1155
GREM_ALWAYS_INLINE bool try_lock_for(const DurationBase< Rep, Period > &timeoutDuration)
Definition synchronization.hpp:1146
GREM_ALWAYS_INLINE void lock()
Definition synchronization.hpp:1131
constexpr RecursiveTimedMutex() noexcept=default
GREM_ALWAYS_INLINE bool try_lock()
Definition synchronization.hpp:1137
ScopedLock(const ScopedLock &)=delete
MutexType mutex_type
Definition synchronization.hpp:1348
ScopedLock & operator=(const ScopedLock &)=delete
GREM_ALWAYS_INLINE ScopedLock(AdoptLock, mutex_type &mutex)
Definition synchronization.hpp:1362
GREM_ALWAYS_INLINE ScopedLock(mutex_type &mutex)
Definition synchronization.hpp:1357
GREM_ALWAYS_INLINE ~ScopedLock()
Definition synchronization.hpp:1365
GREM_ALWAYS_INLINE ~ScopedLock()
Definition synchronization.hpp:1327
GREM_ALWAYS_INLINE ScopedLock(MutexTypes &... mutexes)
Definition synchronization.hpp:1319
GREM_ALWAYS_INLINE ScopedLock(AdoptLock, MutexTypes &... mutexes)
Definition synchronization.hpp:1324
ScopedLock & operator=(const ScopedLock &)=delete
ScopedLock(const ScopedLock &)=delete
SharedLock & operator=(const SharedLock &)=delete
SharedLock() noexcept=default
GREM_ALWAYS_INLINE SharedLock(mutex_type &mutex, const TimePoint &timeoutTime)
Definition synchronization.hpp:1669
MutexType mutex_type
Definition synchronization.hpp:1606
GREM_ALWAYS_INLINE friend void swap(SharedLock &a, SharedLock &b) noexcept
Definition synchronization.hpp:1780
GREM_ALWAYS_INLINE mutex_type * release() noexcept
Definition synchronization.hpp:1784
GREM_ALWAYS_INLINE SharedLock(SharedLock &&other) noexcept
Definition synchronization.hpp:1635
GREM_ALWAYS_INLINE SharedLock & operator=(SharedLock &&other)
Definition synchronization.hpp:1684
GREM_ALWAYS_INLINE SharedLock(mutex_type &mutex, TryToLock)
Definition synchronization.hpp:1648
GREM_ALWAYS_INLINE bool try_lock_until(TimePoint timeoutTime)
Definition synchronization.hpp:1748
GREM_ALWAYS_INLINE SharedLock(mutex_type &mutex, DeferLock) noexcept
Definition synchronization.hpp:1645
GREM_ALWAYS_INLINE ~SharedLock()
Definition synchronization.hpp:1678
GREM_ALWAYS_INLINE bool try_lock()
Definition synchronization.hpp:1726
GREM_ALWAYS_INLINE SharedLock(mutex_type &mutex, const DurationBase< Rep, Period > &timeoutDuration)
Definition synchronization.hpp:1660
GREM_ALWAYS_INLINE bool owns_lock() const noexcept
Definition synchronization.hpp:1801
GREM_ALWAYS_INLINE bool try_lock_for(const DurationBase< Rep, Period > &timeoutDuration)
Definition synchronization.hpp:1737
GREM_ALWAYS_INLINE void swap(SharedLock &other) noexcept
Definition synchronization.hpp:1771
GREM_ALWAYS_INLINE SharedLock(mutex_type &mutex)
Definition synchronization.hpp:1639
GREM_ALWAYS_INLINE void lock()
Definition synchronization.hpp:1696
GREM_ALWAYS_INLINE SharedLock(mutex_type &mutex, AdoptLock)
Definition synchronization.hpp:1655
GREM_ALWAYS_INLINE mutex_type * mutex() const noexcept
Definition synchronization.hpp:1793
GREM_ALWAYS_INLINE void unlock()
Definition synchronization.hpp:1759
GREM_ALWAYS_INLINE void unlock_shared()
Definition synchronization.hpp:1060
GREM_ALWAYS_INLINE void unlock()
Definition synchronization.hpp:1040
GREM_ALWAYS_INLINE bool try_lock()
Definition synchronization.hpp:1032
GREM_ALWAYS_INLINE void lock_shared()
Definition synchronization.hpp:1046
GREM_ALWAYS_INLINE bool try_lock_shared()
Definition synchronization.hpp:1052
GREM_ALWAYS_INLINE void lock()
Definition synchronization.hpp:1026
constexpr SharedMutex() noexcept=default
constexpr SharedTimedMutex() noexcept=default
GREM_ALWAYS_INLINE bool try_lock()
Definition synchronization.hpp:1189
GREM_ALWAYS_INLINE bool try_lock_shared_for(const DurationBase< Rep, Period > &timeoutDuration)
Definition synchronization.hpp:1237
GREM_ALWAYS_INLINE void unlock_shared()
Definition synchronization.hpp:1255
GREM_ALWAYS_INLINE void lock_shared()
Definition synchronization.hpp:1222
GREM_ALWAYS_INLINE bool try_lock_shared()
Definition synchronization.hpp:1228
GREM_ALWAYS_INLINE bool try_lock_until(const TimePoint &timeoutTime)
Definition synchronization.hpp:1207
GREM_ALWAYS_INLINE void unlock()
Definition synchronization.hpp:1216
GREM_ALWAYS_INLINE void lock()
Definition synchronization.hpp:1183
GREM_ALWAYS_INLINE bool try_lock_shared_until(const TimePoint &timeoutTime)
Definition synchronization.hpp:1246
GREM_ALWAYS_INLINE bool try_lock_for(const DurationBase< Rep, Period > &timeoutDuration)
Definition synchronization.hpp:1198
GREM_ALWAYS_INLINE void unlock()
Definition synchronization.hpp:1112
constexpr TimedMutex() noexcept=default
GREM_ALWAYS_INLINE bool try_lock()
Definition synchronization.hpp:1085
GREM_ALWAYS_INLINE void lock()
Definition synchronization.hpp:1079
GREM_ALWAYS_INLINE bool try_lock_until(const TimePoint &timeoutTime)
Definition synchronization.hpp:1103
GREM_ALWAYS_INLINE bool try_lock_for(const DurationBase< Rep, Period > &timeoutDuration)
Definition synchronization.hpp:1094
GREM_ALWAYS_INLINE UniqueLock(UniqueLock &&other) noexcept
Definition synchronization.hpp:1413
UniqueLock() noexcept=default
GREM_ALWAYS_INLINE UniqueLock(mutex_type &mutex)
Definition synchronization.hpp:1417
GREM_ALWAYS_INLINE bool try_lock()
Definition synchronization.hpp:1504
GREM_ALWAYS_INLINE ~UniqueLock()
Definition synchronization.hpp:1456
GREM_ALWAYS_INLINE UniqueLock(mutex_type &mutex, const DurationBase< Rep, Period > &timeoutDuration)
Definition synchronization.hpp:1438
GREM_ALWAYS_INLINE bool try_lock_until(TimePoint timeoutTime)
Definition synchronization.hpp:1525
GREM_ALWAYS_INLINE bool owns_lock() const noexcept
Definition synchronization.hpp:1578
GREM_ALWAYS_INLINE UniqueLock(mutex_type &mutex, DeferLock) noexcept
Definition synchronization.hpp:1423
GREM_ALWAYS_INLINE void lock()
Definition synchronization.hpp:1474
GREM_ALWAYS_INLINE void swap(UniqueLock &other) noexcept
Definition synchronization.hpp:1548
GREM_ALWAYS_INLINE UniqueLock & operator=(UniqueLock &&other)
Definition synchronization.hpp:1462
GREM_ALWAYS_INLINE mutex_type * mutex() const noexcept
Definition synchronization.hpp:1570
GREM_ALWAYS_INLINE UniqueLock(mutex_type &mutex, TryToLock)
Definition synchronization.hpp:1426
GREM_ALWAYS_INLINE void unlock()
Definition synchronization.hpp:1536
GREM_ALWAYS_INLINE mutex_type * release() noexcept
Definition synchronization.hpp:1561
UniqueLock & operator=(const UniqueLock &)=delete
GREM_ALWAYS_INLINE bool try_lock_for(const DurationBase< Rep, Period > &timeoutDuration)
Definition synchronization.hpp:1515
MutexType mutex_type
Definition synchronization.hpp:1384
GREM_ALWAYS_INLINE UniqueLock(mutex_type &mutex, AdoptLock)
Definition synchronization.hpp:1433
GREM_ALWAYS_INLINE UniqueLock(mutex_type &mutex, const TimePoint &timeoutTime)
Definition synchronization.hpp:1447
GREM_ALWAYS_INLINE friend void swap(UniqueLock &a, UniqueLock &b) noexcept
Definition synchronization.hpp:1557
@ T
't'
Definition keyboard.hpp:90
std::error_code make_error_code(EndpointError error)
Create a std::error_code from an EndpointError value.
Definition Error.hpp:153
Definition aliases.hpp:18
constexpr tuple_element_t< Index, Pair< T1, T2 > > & get(Pair< T1, T2 > &t) noexcept
Definition Pair.hpp:202
constexpr DeferLock DEFER_LOCK
Definition synchronization.hpp:1297
Clock::time_point TimePoint
Definition Clock.hpp:26
GREM_ALWAYS_INLINE void lock(Lockable1 &lock1, Lockable2 &lock2, LockableN &... lockN)
Definition synchronization.hpp:1268
MemoryOrder
Definition synchronization.hpp:31
@ CONSUME
Definition synchronization.hpp:41
@ ACQUIRE_RELEASE
Definition synchronization.hpp:44
@ ACQUIRE
Definition synchronization.hpp:42
@ RELAXED
Definition synchronization.hpp:40
@ RELEASE
Definition synchronization.hpp:43
@ SEQUENTIALLY_CONSISTENT
Definition synchronization.hpp:45
constexpr TryToLock TRY_TO_LOCK
Definition synchronization.hpp:1302
std::chrono::duration< Rep, Period > DurationBase
Definition time.hpp:39
GREM_ALWAYS_INLINE T killDependency(T y) noexcept
Definition synchronization.hpp:586
GREM_ALWAYS_INLINE void atomicThreadFence(MemoryOrder order) noexcept
Definition synchronization.hpp:569
constexpr AdoptLock ADOPT_LOCK
Definition synchronization.hpp:1307
GREM_ALWAYS_INLINE void atomicSignalFence(MemoryOrder order) noexcept
Definition synchronization.hpp:577
Definition synchronization.hpp:1304
Definition synchronization.hpp:1294
Definition synchronization.hpp:1299