init_mutex.hpp: More fixes

This commit is contained in:
Eladash 2024-03-06 19:27:58 +02:00 committed by Elad.Ash
parent 5e24167d6c
commit 4512c10ce5
1 changed files with 11 additions and 3 deletions

View File

@ -63,9 +63,6 @@ namespace stx
if (val & c_init_bit) if (val & c_init_bit)
{ {
// Failure
_this = nullptr;
if constexpr (Forced()()) if constexpr (Forced()())
{ {
// Forced reset // Forced reset
@ -73,12 +70,23 @@ namespace stx
while (val != 1) while (val != 1)
{ {
if constexpr (sizeof...(FAndArgs))
{
if (!invoked_func)
{
invoke_callback(0, std::forward<FAndArgs>(args)...);
invoked_func = true;
}
}
// Wait for other users to finish their work // Wait for other users to finish their work
_this->m_state.wait(val); _this->m_state.wait(val);
val = _this->m_state; val = _this->m_state;
} }
} }
// Failure
_this = nullptr;
break; break;
} }