ALib C++ Framework
by
Library Version: 2605 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::threads::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 187 of file dbgasserters.hpp.

#include <dbgasserters.hpp>

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

Public Static Field Index:

static const char * ASSERTION_FORMAT_SHARED
Public Static Field Index: inherited from alib::threads::DbgLockAsserter
static const char * ASSERTION_FORMAT

Public Field Index:

std::atomic< int > CntSharedAcquirements {0}
 The number of shared acquirements.
ActionInfo SAcq
 The most recent shared acquirement's caller.
ActionInfo SRel
 The most recent shared release caller.
Public Field Index: inherited from alib::threads::DbgLockAsserter
ActionInfo Acq
 Source location of the most recent acquirement.
std::atomic< int > ActionCounter {1}
 Counter of the actions.
std::atomic< int > CntAcquirements {0}
 The number of shared acquirements.
const char * Name ="<unnamed>"
int RecursionLimit =10
ActionInfo Rel
 Source location of the most recent release.
Ticks::Duration WaitTimeLimit = Ticks::Duration::FromAbsoluteSeconds(2)

Public Method Index:

virtual ~DbgSharedLockAsserter () override
 Destructor.
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)
ThreadGetOwner () const
bool IsOwnedByCurrentThread () const
void Release (const CallerInfo &assertCI, const CallerInfo &requestCI)
void SetOwner (const CallerInfo &assertCI, const CallerInfo &requestCI)
void SetRecursiveOwner (const CallerInfo &assertCI, const CallerInfo &requestCI)
bool WillRelease () const noexcept

Field Details:

◆ ASSERTION_FORMAT_SHARED

const char * alib::threads::DbgSharedLockAsserter::ASSERTION_FORMAT_SHARED
static
Initial value:
=
"Multi-Threading {} in Shared-Lock \"{}\"" "\n"
" Message: {}" "\n"
" In (Member-)Function: {}" "\n"
" Is Owned: {} ({})" "\n"
" Is Shared Owned: {} ({})" "\n"
"\n"
" Called By: {}::{}" "\n"
" At: {}:{}" "\n"
" Thread: {}" "\n"
"\n"
" Latest Acquisition By: {}::{}" "\n"
" At: {}:{}" "\n"
" Seq / Thread: {} / {}" "\n"
" Latest Release By: {}::{}" "\n"
" At: {}:{}" "\n"
" Seq / Thread: {} / {}" "\n"
"\n"
" Latest Shared Acquisition By: {}::{}" "\n"
" At: {}:{}" "\n"
" Seq / Thread: {} / {}" "\n"
" Latest SharedRelease By: {}::{}" "\n"
" At: {}:{}" "\n"
" Seq / Thread: {} / {}" "\n"

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: {}:{}
                  Seq / Thread: {} / {}
             Latest Release By: {}::{}
                            At: {}:{}
                  Seq / Thread: {} / {}

  Latest Shared Acquisition By: {}::{}
                            At: {}:{}
                  Seq / Thread: {} / {}
       Latest SharedRelease By: {}::{}
                            At: {}:{}
                  Seq / 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-18: ActionInfo of the latest acquisition.
  • 19-24: ActionInfo of the latest release.
  • 25-30: ActionInfo of the latest shared-acquisition.
  • 31-36: ActionInfo of the latest shared-release.

Definition at line 241 of file dbgasserters.hpp.

◆ CntSharedAcquirements

std::atomic<int> alib::threads::DbgSharedLockAsserter::CntSharedAcquirements {0}

The number of shared acquirements.

Definition at line 190 of file dbgasserters.hpp.

◆ SAcq

ActionInfo alib::threads::DbgSharedLockAsserter::SAcq

The most recent shared acquirement's caller.

Definition at line 188 of file dbgasserters.hpp.

◆ SRel

ActionInfo alib::threads::DbgSharedLockAsserter::SRel

The most recent shared release caller.

Definition at line 189 of file dbgasserters.hpp.

Constructor(s) / Destructor Details:

◆ ~DbgSharedLockAsserter()

virtual alib::threads::DbgSharedLockAsserter::~DbgSharedLockAsserter ( )
inlineoverridevirtual

Destructor.

Definition at line 245 of file dbgasserters.hpp.

Method Details:

◆ DoAssert()

void alib::threads::DbgSharedLockAsserter::DoAssert ( int type,
const CallerInfo & assertCI,
const CallerInfo & ci,
const char * headline )
overridevirtual

Assembles assertion info and raises a warning or an error.

See also
Inherited 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 alib::threads::DbgLockAsserter.

Definition at line 73 of file dbgasserters.cpp.

Here is the call graph for this function:

◆ IsSharedOwnedByAnyThread()

bool alib::threads::DbgSharedLockAsserter::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 267 of file dbgasserters.hpp.

◆ ReleaseShared()

void alib::threads::DbgSharedLockAsserter::ReleaseShared ( const CallerInfo & assertCI,
const CallerInfo & requestCI )
inline

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

Parameters
assertCILocation where the release is implemented.
requestCILocation where the release was requested (the caller of assertCI)

Definition at line 302 of file dbgasserters.hpp.

Here is the call graph for this function:

◆ SetOwner()

void alib::threads::DbgSharedLockAsserter::SetOwner ( const CallerInfo & assertCI,
const CallerInfo & requestCI )
inline

Sets the given caller as the current owner. Asserts that CntAcquirements is 0 when called.

Parameters
assertCILocation where ownership was implemented (usually the lock).
requestCILocation where ownership was requested (the caller of assertCI)

Definition at line 273 of file dbgasserters.hpp.

Here is the call graph for this function:

◆ SetSharedOwner()

void alib::threads::DbgSharedLockAsserter::SetSharedOwner ( const CallerInfo & assertCI,
const CallerInfo & requestCI,
int warnLimit )
inline

Sets the given caller as a current shared-owner. Asserts that CntAcquirements is 0 when called.

Parameters
assertCILocation where ownership was implemented (usually the lock).
requestCILocation where ownership was requested (the caller of assertCI)
warnLimitIf this number of shared acquisitions is exceeded, a warning is given.

Definition at line 285 of file dbgasserters.hpp.

Here is the call graph for this function:

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