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

Description:

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 192 of file dbglockasserter.hpp.

#include <dbglockasserter.hpp>

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

Public Static Field Index:

static ALIB_API NString ASSERTION_FORMAT_SHARED
 
- Public Static Field Index: inherited from DbgLockAsserter
static ALIB_API NString ASSERTION_FORMAT
 

Public Field Index:

std::atomic< int > CntSharedAcquirements {0}
 The number of shared acquirements.
 
CallerInfo SAcqCI
 Source location of the most recent shared acquirement.
 
CallerInfo SRelCI
 Source location of the most recent shared release.
 
- Public Field Index: inherited from DbgLockAsserter
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 ~DbgSharedLockAsserter () override
 Destructor.
 
void AssertNotOwned (const CallerInfo &assertCI, const CallerInfo &ci, const NString &headline)
 
ALIB_API void DoAssert (int type, const CallerInfo &assertCI, const CallerInfo &ci, const NString &headline) override
 
bool IsSharedOwnedByAnyThread () const
 
- Public Method Index: inherited from DbgLockAsserter
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)
 
ALIB_API ThreadGetOwner () const
 
bool IsOwnedByCurrentThread () const
 
bool WillRelease () const noexcept
 

Field Details:

◆ ASSERTION_FORMAT_SHARED

ALIB_API NString ASSERTION_FORMAT_SHARED
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}
               Is Shared Owned: {10}
                     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}
  Latest Shared Acquisition By: {8:ya}
                            At: {8:sf:sl}
                        Thread: {8:ta}
       Latest SharedRelease By: {9:ya}
                            At: {9:sf:sl}
                        Thread: {9: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
  • 8: CallerInfo of latest shared acquisition.
  • 9: CallerInfo of latest shared release.
  • 10: Shared 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 247 of file dbglockasserter.hpp.

◆ CntSharedAcquirements

std::atomic<int> CntSharedAcquirements {0}

The number of shared acquirements.

Definition at line 196 of file dbglockasserter.hpp.

◆ SAcqCI

CallerInfo SAcqCI

Source location of the most recent shared acquirement.

Definition at line 194 of file dbglockasserter.hpp.

◆ SRelCI

CallerInfo SRelCI

Source location of the most recent shared release.

Definition at line 195 of file dbglockasserter.hpp.

Constructor(s) / Destructor Details:

◆ ~DbgSharedLockAsserter()

virtual ~DbgSharedLockAsserter ( )
inlineoverridevirtual

Destructor.

Definition at line 252 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 280 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 )
overridevirtual

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 from DbgLockAsserter.

Definition at line 142 of file locks.cpp.

Here is the call graph for this function:

◆ IsSharedOwnedByAnyThread()

bool IsSharedOwnedByAnyThread ( ) const
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.

Returns
true, if the lock is owned by this thread, false if it is owned by another thread or not owned.

Definition at line 274 of file dbglockasserter.hpp.


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