ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
DbgLockAsserter Struct Reference

Description:

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>

Inheritance diagram for DbgLockAsserter:
[legend]
Collaboration diagram for DbgLockAsserter:
[legend]

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 ThreadGetOwner () const
 
bool IsOwnedByCurrentThread () const
 
bool WillRelease () const noexcept
 

Field Details:

◆ AcqCI

CallerInfo AcqCI

Source location of the most recent acquirement.

Definition at line 34 of file dbglockasserter.hpp.

◆ ASSERTION_FORMAT

ALIB_API NString ASSERTION_FORMAT
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 {!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 string

The format specification of the type CallerInfo is defined with class FMTCallerInfo.

Availability:
This field is only available with the inclusion of ALib BaseCamp in the ALib Distribution.

Definition at line 78 of file dbglockasserter.hpp.

◆ CntAcquirements

int16_t CntAcquirements = 0

The number of nested acquirements.

Definition at line 36 of file dbglockasserter.hpp.

◆ Name

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.

◆ RecursionLimit

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.

◆ RelCI

CallerInfo RelCI

Source location of the most recent release.

Definition at line 35 of file dbglockasserter.hpp.

◆ WaitTimeLimit

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.

Constructor(s) / Destructor Details:

◆ ~DbgLockAsserter()

virtual ~DbgLockAsserter ( )
inlinevirtual

Destructor.

Definition at line 96 of file dbglockasserter.hpp.

Method Details:

◆ AssertNotOwned()

void AssertNotOwned ( const CallerInfo & assertCI,
const CallerInfo & ci,
const NString & headline )
inline

Asserts that CntAcquirements is 0

Parameters
assertCILocation where the assertion is placed.
ciLocation of the call to the method that asserted.
headlineThe message.

Definition at line 150 of file dbglockasserter.hpp.

Here is the call graph for this function:

◆ AssertNotOwnedOrMe()

void AssertNotOwnedOrMe ( const CallerInfo & assertCI,
const CallerInfo & ci,
const NString & headline )
inline

Asserts that either CntAcquirements is 0 or the lock is owned by calling thread.

Parameters
assertCILocation where the assertion is placed.
ciLocation of the call to the method that asserted.
headlineThe message.

Definition at line 160 of file dbglockasserter.hpp.

Here is the call graph for this function:

◆ AssertNotOwning()

void AssertNotOwning ( const CallerInfo & assertCI,
const CallerInfo & ci,
const NString & headline )
inline

Asserts that this lock is not owned by the thread in ci.

Parameters
assertCILocation where the assertion is placed.
ciLocation of the call to the method that asserted.
headlineThe message.

Definition at line 180 of file dbglockasserter.hpp.

Here is the call graph for this function:

◆ AssertOwned()

void AssertOwned ( const CallerInfo & assertCI,
const CallerInfo & ci,
const NString & headline )
inline

Asserts that CntAcquirements is not 0

Parameters
assertCILocation where the assertion is placed.
ciLocation of the call to the method that asserted.
headlineThe message.

Definition at line 140 of file dbglockasserter.hpp.

Here is the call graph for this function:

◆ AssertOwning()

void AssertOwning ( const CallerInfo & assertCI,
const CallerInfo & ci,
const NString & headline )
inline

Asserts that this lock is owned by the thread in ci.

Parameters
assertCILocation where the assertion is placed.
ciLocation of the call to the method that asserted.
headlineThe message.

Definition at line 170 of file dbglockasserter.hpp.

Here is the call graph for this function:

◆ DoAssert()

void DoAssert ( int type,
const CallerInfo & assertCI,
const CallerInfo & ci,
const NString & headline )
virtual

Writes assertion info and calls ALIB_ASSERT, respectively ALIB_WARNING.

See also
Field ASSERTION_FORMAT which allows changing the output format to achieve 'clickable' assertion messages.
Parameters
type0= assertion, 1= warning.
assertCILocation where the assertion is placed.
ciLocation of the call to the method that asserted.
headlineThe message.

Reimplemented in DbgSharedLockAsserter.

Definition at line 97 of file locks.cpp.

Here is the call graph for this function:

◆ GetOwner()

Thread * GetOwner ( ) const

Returns a pointer the owning thread.

Available only in debug-builds.

Returns
Pointer to the owning thread, or nullptr if not owned.

Definition at line 43 of file locks.cpp.

Here is the call graph for this function:

◆ IsOwnedByCurrentThread()

bool IsOwnedByCurrentThread ( ) const
inline

Returns true if the current owner is the current thread.

Available only in debug-builds.

Returns
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.

◆ WillRelease()

bool WillRelease ( ) const
inlinenoexcept

Returns true if this is a non-recursive lock or a recursive instance which is acquired exactly once.
Available only in debug-builds.

Note
This method is not (and cannot) be synchronized. Consequently, a reliable result is only guaranteed in case IsOwnedByCurrentThread returns true before this method is invoked.
Returns
true if the next release will free this lock, false otherwise.

Definition at line 121 of file dbglockasserter.hpp.


The documentation for this struct was generated from the following files: