This type is used for debugging and asserting ALib lock (mutex) types. With debug compilations the shared lock types hold one member of this struct, which aggregates all debug information.
Definition at line 178 of file dbgasserters.inl.
Public Static Field Index: | |
| static ALIB_DLL const char * | ASSERTION_FORMAT_SHARED |
Public Static Field Index: inherited from alib::threads::DbgLockAsserter | |
| static ALIB_DLL const char * | ASSERTION_FORMAT |
Public Field Index: | |
| std::atomic< int > | CntSharedAcquirements {0} |
| The number of shared acquirements. | |
| CallerInfo | SAcqCI |
| The most recent shared acquirement's caller. | |
| CallerInfo | SRelCI |
| The most recent shared release caller. | |
Public Field Index: inherited from alib::threads::DbgLockAsserter | |
| CallerInfo | AcqCI |
| Source location of the most recent acquirement. | |
| std::atomic< int > | CntAcquirements {0} |
| The number of shared 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 | ~DbgSharedLockAsserter () override |
| Destructor. | |
| ALIB_DLL void | DoAssert (int type, const CallerInfo &assertCI, const CallerInfo &ci, const char *headline) override |
| bool | IsSharedOwnedByAnyThread () const |
| void | ReleaseShared (const CallerInfo &assertCI, const CallerInfo &requestCI) |
| void | SetOwner (const CallerInfo &assertCI, const CallerInfo &requestCI) |
| void | SetSharedOwner (const CallerInfo &assertCI, const CallerInfo &requestCI, int warnLimit) |
Public Method Index: inherited from alib::threads::DbgLockAsserter | |
| virtual | ~DbgLockAsserter () |
| Destructor. | |
| void | AssertNotOwning (const CallerInfo &assertCI, const CallerInfo &ci, const char *headline) |
| void | AssertOwned (const CallerInfo &assertCI, const CallerInfo &ci) |
| ALIB_DLL Thread * | GetOwner () const |
| bool | IsOwnedByCurrentThread () const |
| void | Release (const CallerInfo &assertCI, const CallerInfo &requestCI) |
| void | SetOwner (const CallerInfo &assertCI, const CallerInfo &requestCI) |
| ALIB_DLL void | SetRecursiveOwner (const CallerInfo &assertCI, const CallerInfo &requestCI) |
| bool | WillRelease () const noexcept |
|
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-Threading {} in Shared-Lock \"{}\"
Message: {}
In (Member-)Function: {}
Is Owned: {} ({})
Is Shared Owned: {} ({})
Called By: {}::{}
At: {}:{}
Thread: {}
Latest Acquisition By: {}::{}
At: {}:{}
Thread: {}
Latest Release By: {}::{}
At: {}:{}
Thread: {}
Latest Shared Acquisition By: {}::{}
At: {}:{}
Thread: {}
Latest SharedRelease 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: Is shared acquired (true/false).7: number of shared-acquirements.8-12: CallerInfo of caller.13-17: CallerInfo of the latest acquisition.18-22: CallerInfo of the latest release.23-27: CallerInfo of the latest shared-acquisition.32-36: CallerInfo of the latest shared-release. Definition at line 233 of file dbgasserters.inl.
| std::atomic<int> alib::threads::DbgSharedLockAsserter::CntSharedAcquirements {0} |
The number of shared acquirements.
Definition at line 182 of file dbgasserters.inl.
| CallerInfo alib::threads::DbgSharedLockAsserter::SAcqCI |
The most recent shared acquirement's caller.
Definition at line 180 of file dbgasserters.inl.
| CallerInfo alib::threads::DbgSharedLockAsserter::SRelCI |
The most recent shared release caller.
Definition at line 181 of file dbgasserters.inl.
|
inlineoverridevirtual |
Destructor.
Definition at line 237 of file dbgasserters.inl.
|
overridevirtual |
Assembles assertion info and raises a warning or an 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 from alib::threads::DbgLockAsserter.
Definition at line 98 of file dbgasserters.cpp.
|
inline |
Returns true if currently a reader is registered. This method is used to create assertions. of course, to detect assertions, it would be more efficient to check if shared ownership is with the current thread, but a check on this would cost a lot of overhead to realize. This way, at least assertions can be raised when no other thread acquired this lock in shared mode.
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 259 of file dbgasserters.inl.
|
inline |
Asserts that this lock is shared-owned by the thread in ci.
| assertCI | Location where the release is implemented. |
| requestCI | Location where the release was requested (the caller of assertCI) |
Definition at line 296 of file dbgasserters.inl.
|
inline |
Sets the given caller as the current owner. Asserts that CntAcquirements is 0 when called.
| assertCI | Location where ownership was implemented (usually the lock). |
| requestCI | Location where ownership was requested (the caller of assertCI) |
Definition at line 265 of file dbgasserters.inl.
|
inline |
Sets the given caller as a current shared-owner. Asserts that CntAcquirements is 0 when called.
| assertCI | Location where ownership was implemented (usually the lock). |
| requestCI | Location where ownership was requested (the caller of assertCI) |
| warnLimit | If this number of shared acquisitions is exceeded, a warning is given. |
Definition at line 280 of file dbgasserters.inl.