forked from Alepha/Alepha
Some thread interruption defensiveness.
This commit is contained in:
28
Utility/ScopedState.h
Normal file
28
Utility/ScopedState.h
Normal file
@ -0,0 +1,28 @@
|
||||
static_assert( __cplusplus > 2020'00 );
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Alepha/Alepha.h>
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
||||
namespace Alepha::Hydrogen::Utility ::detail:: ScopedState_m
|
||||
{
|
||||
inline namespace exports
|
||||
{
|
||||
class ScopedState : boost::noncopyable
|
||||
{
|
||||
private:
|
||||
bool &state;
|
||||
|
||||
public:
|
||||
~ScopedState() { state= false; }
|
||||
explicit ScopedState( bool &state ) : state( state ) { state= true; }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace Alepha::Hydrogen::Utility::inline exports::inline ScopedState_m
|
||||
{
|
||||
using namespace detail::ScopedState_m::exports;
|
||||
}
|
Reference in New Issue
Block a user