jaulib v1.3.6
Jau Support Library (C++, Java, ..)
Loading...
Searching...
No Matches
jau::RecursiveLock Class Reference

#include <locks.hpp>

Collaboration diagram for jau::RecursiveLock:

Public Types

typedef void(* callback_func) () noexcept
 

Public Member Functions

 RecursiveLock () noexcept
 
 RecursiveLock (const RecursiveLock &)=delete
 
nsize_t holdCount () noexcept
 Return the number of locks issued to this lock by the same thread.
 
bool isOwner () const noexcept
 
bool isOwner (std::thread::id id) const noexcept
 
void lock ()
 Acquire this lock indefinitely (no timeout)
 
void operator= (const RecursiveLock &)=delete
 
std::string toString () const
 
bool tryLock (const fraction_i64 &timeout)
 Try to acquire this lock within given timeout in seconds.
 
void unlock (callback_func taskBeforeUnlock=nullptr)
 Unlock ...
 
void validateLocked () const
 

Detailed Description

Definition at line 46 of file locks.hpp.

Member Typedef Documentation

◆ callback_func

typedef void(* jau::RecursiveLock::callback_func) () noexcept
noexcept

Definition at line 48 of file locks.hpp.

Constructor & Destructor Documentation

◆ RecursiveLock() [1/2]

jau::RecursiveLock::RecursiveLock ( )
inlinenoexcept

Definition at line 56 of file locks.hpp.

Here is the caller graph for this function:

◆ RecursiveLock() [2/2]

jau::RecursiveLock::RecursiveLock ( const RecursiveLock & )
delete

Member Function Documentation

◆ operator=()

void jau::RecursiveLock::operator= ( const RecursiveLock & )
delete

◆ isOwner() [1/2]

bool jau::RecursiveLock::isOwner ( std::thread::id id) const
inlinenoexcept

Definition at line 62 of file locks.hpp.

◆ isOwner() [2/2]

bool jau::RecursiveLock::isOwner ( ) const
inlinenoexcept

Definition at line 63 of file locks.hpp.

Here is the caller graph for this function:

◆ holdCount()

nsize_t jau::RecursiveLock::holdCount ( )
inlinenoexcept

Return the number of locks issued to this lock by the same thread.

  • A hold count of 0 identifies this lock as unlocked.
  • A hold count of 1 identifies this lock as locked.
  • A hold count of > 1 identifies this lock as recursively lock.

Definition at line 73 of file locks.hpp.

◆ lock()

void jau::RecursiveLock::lock ( )
inline

Acquire this lock indefinitely (no timeout)

Definition at line 78 of file locks.hpp.

◆ tryLock()

bool jau::RecursiveLock::tryLock ( const fraction_i64 & timeout)
inline

Try to acquire this lock within given timeout in seconds.

Parameters
timeoutmaximum duration in fractions of seconds to wait, where fractions_i64::zero waits infinitely
Returns
true if successful, otherwise false in case timeout occurred or otherwise.

Definition at line 91 of file locks.hpp.

◆ validateLocked()

void jau::RecursiveLock::validateLocked ( ) const
inline

Definition at line 111 of file locks.hpp.

Here is the caller graph for this function:

◆ unlock()

void jau::RecursiveLock::unlock ( callback_func taskBeforeUnlock = nullptr)
inline

Unlock ...

Parameters
taskBeforeUnlockoptional callback_func to be execiting before final unlock.
See also
lock()
tryLock()

Definition at line 126 of file locks.hpp.

◆ toString()

std::string jau::RecursiveLock::toString ( ) const
inline

Definition at line 140 of file locks.hpp.

Here is the caller graph for this function:

The documentation for this class was generated from the following file: