init_mutex.hpp: Fixup

This commit is contained in:
Eladash 2024-03-06 14:57:42 +02:00 committed by Elad.Ash
parent f40602cc59
commit b64b98490e

View File

@ -58,20 +58,14 @@ namespace stx
if (val == 0) if (val == 0)
{ {
// Success: obtained "init lock" // Success: obtained "init lock"
if constexpr (sizeof...(FAndArgs))
{
if (invoked_func)
{
invoke_callback(1, std::forward<FAndArgs>(args)...);
}
}
break; break;
} }
if (val & c_init_bit) if (val & c_init_bit)
{ {
// Failure
_this = nullptr;
if constexpr (Forced()()) if constexpr (Forced()())
{ {
// Forced reset // Forced reset
@ -83,19 +77,6 @@ namespace stx
_this->m_state.wait(val); _this->m_state.wait(val);
val = _this->m_state; val = _this->m_state;
} }
break;
}
// Failure
_this = nullptr;
if constexpr (sizeof...(FAndArgs))
{
if (invoked_func)
{
invoke_callback(1, std::forward<FAndArgs>(args)...);
}
} }
break; break;
@ -112,6 +93,15 @@ namespace stx
_this->m_state.wait(val); _this->m_state.wait(val);
} }
// Finalization of wait callback
if constexpr (sizeof...(FAndArgs))
{
if (invoked_func)
{
invoke_callback(1, std::forward<FAndArgs>(args)...);
}
}
} }
init_lock(const init_lock&) = delete; init_lock(const init_lock&) = delete;