10#if !defined(HPP_ALIB_THREADS_SMARTLOCK)
14#if !defined (_GLIBCXX_ALGORITHM) && !defined(_ALGORITHM_)
19namespace alib {
namespace threads {
26 return static_cast<int>(
acquirers.size() );
33 bool errAlreadyAdded=
true;
34 int errWasAcquired= 0; )
41 if ( newAcquirer ==
nullptr
45 errAlreadyAdded=
false;
54 if ( firstAcquirer !=
nullptr )
71 if ( errWasAcquired == 1 )
86 ALIB_ASSERT_ERROR( errWasAcquired!=1,
"THREADS",
"Already acquired. Hint: Acquirer[0] must not acquire this before adding itself!" )
87 ALIB_ASSERT_ERROR( errWasAcquired!=2,
"THREADS",
"Acquired and acquirer[0] anonymous. Misuse of SmartLock!" )
89 return static_cast<int>( count );
97 bool errNotFound=
true; )
109 errNotFound=
false; )
116 if( acquirer1== acquirerToRemove ) acquirer1=
nullptr;
117 if( acquirer2== acquirerToRemove ) acquirer2=
nullptr;
124 if ( acquirer2 !=
nullptr ) acquirer2->
Release();
125 if ( acquirer1 !=
nullptr ) acquirer1->
Release();
136 ALIB_ASSERT_ERROR( !errWasAcquired,
"THREADS",
"Acquired on release. Hint: Acquirers must acquire only when acquired themselves!" )
137 return static_cast<int>( count );
ALIB_API int RemoveAcquirer(ThreadLock *acquirer)
std::vector< ThreadLock * > acquirers
ALIB_API int CntAcquirers()
ALIB_API int AddAcquirer(ThreadLock *newAcquirer)
static ALIB_API SmartLock StdOutputStreams
ALIB_API void Acquire(const NCString &dbgFile, int dbgLine, const NCString &dbgFunc)
ALIB_API void SetSafeness(lang::Safeness safeness)
int CountAcquirements() const
ALIB_API void Release()
defined(ALIB_DOX)
#define ALIB_ASSERT_ERROR(cond,...)
#define ALIB_CALLER_PRUNED
#define ALIB_LOCK_WITH(lock)
@ Safe
Do it or treat it with safety.
@ Unsafe
Omit checks or perform unsafe operations.
threads::SmartLock SmartLock
Type alias in namespace alib.