This type is used for debugging and asserting ALib lock (mutex) types. With debug compilations the non-shared lock types hold one member of this struct, which aggregates all debug information.
Definition at line 27 of file dbglockasserter.hpp.
#include <dbglockasserter.hpp>
Public Static Field Index: | |
static ALIB_API NString | ASSERTION_FORMAT |
Public Field Index: | |
CallerInfo | AcqCI |
Source location of the most recent acquirement. | |
int16_t | CntAcquirements = 0 |
The number of nested acquirements. | |
const char * | Name ="<unnamed>" |
int | RecursionLimit =10 |
CallerInfo | RelCI |
Source location of the most recent release. | |
Ticks::Duration | WaitTimeLimit = Ticks::Duration::FromAbsoluteSeconds(2) |
Public Method Index: | |
virtual | ~DbgLockAsserter () |
Destructor. | |
void | AssertNotOwned (const CallerInfo &assertCI, const CallerInfo &ci, const NString &headline) |
void | AssertNotOwnedOrMe (const CallerInfo &assertCI, const CallerInfo &ci, const NString &headline) |
void | AssertNotOwning (const CallerInfo &assertCI, const CallerInfo &ci, const NString &headline) |
void | AssertOwned (const CallerInfo &assertCI, const CallerInfo &ci, const NString &headline) |
void | AssertOwning (const CallerInfo &assertCI, const CallerInfo &ci, const NString &headline) |
virtual ALIB_API void | DoAssert (int type, const CallerInfo &assertCI, const CallerInfo &ci, const NString &headline) |
ALIB_API Thread * | GetOwner () const |
bool | IsOwnedByCurrentThread () const |
bool | WillRelease () const noexcept |
CallerInfo AcqCI |
Source location of the most recent acquirement.
Definition at line 34 of file dbglockasserter.hpp.
The format string used to write exceptions to the console. This string can be changed if the source information is not "clickable" in a user's development environment.
The default string is optimized for JetBrains CLion and is defined as:
Multi-Threadding {} in Lock {!Q} Message: {} In (Member-)Function: {:ya} Is Owned: {7} Called By: {4:ya} At: {4:sf:sl} Thread: {4:ta} Latest Acquisition By: {5:ya} At: {5:sf:sl} Thread: {5:ta} Latest Release By: {6:ya} At: {6:sf:sl} Thread: {6:ta}
The placeholder fields that this format string refers to are set as follows:
0
: String "Assertion" or "Warning"1
: Debug-name of the lock.2
: Headline.3
: CallerInfo of assertion.4
: CallerInfo of caller.5
: CallerInfo of latest acquisition.6
: CallerInfo of latest release.7
: Acquirement information stringThe format specification of the type CallerInfo
is defined with class FMTCallerInfo.
Definition at line 78 of file dbglockasserter.hpp.
int16_t CntAcquirements = 0 |
The number of nested acquirements.
Definition at line 36 of file dbglockasserter.hpp.
const char* Name ="<unnamed>" |
The name of this Lock. Set to "<unnamed>" by default. Used for debug-output. For automatic pruning of changes to this name, macro ALIB_DBG should be used.
Definition at line 33 of file dbglockasserter.hpp.
int RecursionLimit =10 |
Limit of recursions. If the limit is reached or a multiple of it, a warning is passed to ReportWriter. Defaults is 10
. To disable, set to 0
.
Available only in debug versions of ALib.
Definition at line 93 of file dbglockasserter.hpp.
CallerInfo RelCI |
Source location of the most recent release.
Definition at line 35 of file dbglockasserter.hpp.
Ticks::Duration WaitTimeLimit = Ticks::Duration::FromAbsoluteSeconds(2) |
This is a threshold that causes non-timed Acquire() methods to raise a ALib warning in debug-builds in case a thread is blocked longer than the given duration.
To disable warnings in cases that high block times are suitable, set this value to 0
. The default value is two seconds.
Definition at line 87 of file dbglockasserter.hpp.
|
inlinevirtual |
Destructor.
Definition at line 96 of file dbglockasserter.hpp.
|
inline |
Asserts that CntAcquirements is 0
assertCI | Location where the assertion is placed. |
ci | Location of the call to the method that asserted. |
headline | The message. |
Definition at line 150 of file dbglockasserter.hpp.
|
inline |
Asserts that either CntAcquirements is 0
or the lock is owned by calling thread.
assertCI | Location where the assertion is placed. |
ci | Location of the call to the method that asserted. |
headline | The message. |
Definition at line 160 of file dbglockasserter.hpp.
|
inline |
Asserts that this lock is not owned by the thread in ci.
assertCI | Location where the assertion is placed. |
ci | Location of the call to the method that asserted. |
headline | The message. |
Definition at line 180 of file dbglockasserter.hpp.
|
inline |
Asserts that CntAcquirements is not 0
assertCI | Location where the assertion is placed. |
ci | Location of the call to the method that asserted. |
headline | The message. |
Definition at line 140 of file dbglockasserter.hpp.
|
inline |
Asserts that this lock is owned by the thread in ci.
assertCI | Location where the assertion is placed. |
ci | Location of the call to the method that asserted. |
headline | The message. |
Definition at line 170 of file dbglockasserter.hpp.
|
virtual |
Writes assertion info and calls ALIB_ASSERT, respectively ALIB_WARNING.
type | 0= assertion, 1= warning. |
assertCI | Location where the assertion is placed. |
ci | Location of the call to the method that asserted. |
headline | The message. |
Reimplemented in DbgSharedLockAsserter.
Definition at line 97 of file locks.cpp.
Thread * GetOwner | ( | ) | const |
|
inline |
Returns true
if the current owner is the current thread.
Available only in debug-builds.
true
, if the lock is owned by this thread, false
if it is owned by another thread or not owned. Definition at line 108 of file dbglockasserter.hpp.
|
inlinenoexcept |
Returns true
if this is a non-recursive lock or a recursive instance which is acquired exactly once.
Available only in debug-builds.
true
before this method is invoked.true
if the next release will free this lock, false
otherwise. Definition at line 121 of file dbglockasserter.hpp.