75 if (!handler || owner == NoOwner)
78 size_t expected = Empty;
79 if (!__atomic_compare_exchange_n(&m_State, &expected, Publishing,
false, __ATOMIC_ACQ_REL,
84 __atomic_store_n(&m_Owner, owner, __ATOMIC_RELAXED);
85 __atomic_store_n(&m_Handler, handler, __ATOMIC_RELEASE);
86 __atomic_store_n(&m_State, Published, __ATOMIC_RELEASE);
98 if (!handler || owner == NoOwner || __atomic_load_n(&m_Owner, __ATOMIC_ACQUIRE) != owner)
101 if (__atomic_load_n(&m_Handler, __ATOMIC_ACQUIRE) != handler)
107 size_t expected = Published;
108 if (!__atomic_compare_exchange_n(&m_State, &expected, Removing,
false, __ATOMIC_ACQ_REL,
114 __atomic_store_n(&m_Owner, NoOwner, __ATOMIC_RELEASE);
115 __atomic_store_n(&m_State, Empty, __ATOMIC_RELEASE);
121 if (guard.m_Slot || owner == NoOwner)
124 if (__atomic_load_n(&m_Owner, __ATOMIC_ACQUIRE) != owner) {
128 size_t observed = __atomic_load_n(&m_State, __ATOMIC_ACQUIRE);
129 while ((observed & ModeMask) == Published) {
130 if ((observed & DispatchCountMask) == DispatchCountMask) {
134 const size_t admitted = observed + DispatchIncrement;
135 if (__atomic_compare_exchange_n(&m_State, &observed, admitted,
false, __ATOMIC_ACQ_REL,
140 if ((observed & ModeMask) != Published) {
145 if (!handler || __atomic_load_n(&m_Owner, __ATOMIC_ACQUIRE) != owner) {
150 guard.m_Handler = handler;
157 const size_t before = __atomic_load_n(&m_State, __ATOMIC_ACQUIRE);
158 if ((before & ModeMask) != Published)
160 return handler && __atomic_load_n(&m_Owner, __ATOMIC_ACQUIRE) == owner &&
161 __atomic_load_n(&m_Handler, __ATOMIC_ACQUIRE) == handler &&
162 __atomic_load_n(&m_State, __ATOMIC_ACQUIRE) == before;