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 17 of file dbgasserters.inl.
Public Static Field Index: | |
static ALIB_DLL const char * | 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 char *headline) |
void | AssertNotOwnedOrMe (const CallerInfo &assertCI, const CallerInfo &ci, const char *headline) |
void | AssertNotOwning (const CallerInfo &assertCI, const CallerInfo &ci, const char *headline) |
void | AssertOwned (const CallerInfo &assertCI, const CallerInfo &ci, const char *headline) |
void | AssertOwning (const CallerInfo &assertCI, const CallerInfo &ci, const char *headline) |
virtual ALIB_DLL void | DoAssert (int type, const CallerInfo &assertCI, const CallerInfo &ci, const char *headline) |
ALIB_DLL Thread * | GetOwner () const |
bool | IsOwnedByCurrentThread () const |
bool | WillRelease () const noexcept |
CallerInfo alib::threads::DbgLockAsserter::AcqCI |
Source location of the most recent acquirement.
Definition at line 24 of file dbgasserters.inl.
|
static |
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 \"{}\" Message: {} In (Member-)Function: {} Is Owned: {} ({}) Called By: {}::{} At: {}:{} Thread: {} Latest Acquisition By: {}::{} At: {}:{} Thread: {} Latest Release By: {}:{} At: {}:{} Thread: {}
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
: Function name.4
: Is acquired (true/false).5
: number of acquirements.6-10
: CallerInfo of caller.11-15
: CallerInfo of the latest acquisition.16-20
: CallerInfo of the latest release. Definition at line 64 of file dbgasserters.inl.
int16_t alib::threads::DbgLockAsserter::CntAcquirements = 0 |
The number of nested acquirements.
Definition at line 26 of file dbgasserters.inl.
const char* alib::threads::DbgLockAsserter::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 23 of file dbgasserters.inl.
int alib::threads::DbgLockAsserter::RecursionLimit =10 |
Limit of recursions. If the limit is reached or a multiple of it, an ALib warning is raised. Defaults is 10
. To disable, set to 0
.
Available only in debug versions of ALib.
Definition at line 78 of file dbgasserters.inl.
CallerInfo alib::threads::DbgLockAsserter::RelCI |
Source location of the most recent release.
Definition at line 25 of file dbgasserters.inl.
Ticks::Duration alib::threads::DbgLockAsserter::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 72 of file dbgasserters.inl.
|
inlinevirtual |
Destructor.
Definition at line 81 of file dbgasserters.inl.
|
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 135 of file dbgasserters.inl.
|
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 145 of file dbgasserters.inl.
|
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 165 of file dbgasserters.inl.
|
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 125 of file dbgasserters.inl.
|
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 155 of file dbgasserters.inl.
|
virtual |
Collects assertion info and raises a warning or error.
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 alib::threads::DbgSharedLockAsserter.
Definition at line 85 of file dbgasserters.cpp.
Thread * alib::threads::DbgLockAsserter::GetOwner | ( | ) | const |
Returns a pointer the owning thread.
Available only in debug-builds.
nullptr
if not owned. Definition at line 33 of file dbgasserters.cpp.
|
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 93 of file dbgasserters.inl.
|
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 106 of file dbgasserters.inl.