forked from Alepha/Alepha
Some thread interruption defensiveness.
This commit is contained in:
@ -8,6 +8,7 @@ static_assert( __cplusplus > 2020'99 );
|
||||
|
||||
#include <Alepha/Utility/StaticValue.h>
|
||||
#include <Alepha/Utility/evaluation_helpers.h>
|
||||
#include <Alepha/Utility/ScopedState.h>
|
||||
|
||||
#include "error.h"
|
||||
|
||||
@ -131,6 +132,7 @@ namespace Alepha::Hydrogen::detail::Thread_m
|
||||
while( impl().state == Opening )
|
||||
{
|
||||
impl().var.wait( lock );
|
||||
assert( not impl().threadBlocked );
|
||||
}
|
||||
|
||||
if( impl().state == Open )
|
||||
@ -167,9 +169,9 @@ namespace Alepha::Hydrogen::detail::Thread_m
|
||||
{
|
||||
if( impl().state == Waiting )
|
||||
{
|
||||
impl().threadBlocked= true;
|
||||
while( impl().state == Waiting )
|
||||
{
|
||||
Utility::ScopedState state{ impl().threadBlocked };
|
||||
impl().var.wait( lock );
|
||||
}
|
||||
assert( not impl().threadBlocked );
|
||||
@ -179,9 +181,7 @@ namespace Alepha::Hydrogen::detail::Thread_m
|
||||
else if( impl().state == Synchronizing )
|
||||
{
|
||||
impl().state= Opening;
|
||||
const bool unblock= impl().threadBlocked;
|
||||
impl().threadBlocked= false;
|
||||
if( unblock )
|
||||
if( impl().threadBlocked )
|
||||
{
|
||||
impl().var.notify_one();
|
||||
|
||||
|
Reference in New Issue
Block a user