StormByte C++ Library 1.2.0
StormByte is a comprehensive, cross-platform C++ library aimed at easing system programming, configuration management, logging, and database handling tasks. This library provides a unified API that abstracts away the complexities and inconsistencies of different platforms (Windows, Linux).
Loading...
Searching...
No Matches
Public Member Functions | List of all members
StormByte::ThreadLock Class Referencefinal

Mutex with owner-thread reentry. More...

#include <StormByte/thread_lock.hxx>

Public Member Functions

 ThreadLock () noexcept=default
 Unlocked lock, no owner.
 
 ThreadLock (const ThreadLock &)=delete
 Not copyable.
 
 ThreadLock (ThreadLock &&)=delete
 Not movable (std::mutex is not movable on Windows).
 
 ~ThreadLock () noexcept
 Releases internal mutexes.
 
ThreadLockoperator= (const ThreadLock &)=delete
 Not copy-assignable.
 
ThreadLockoperator= (ThreadLock &&)=delete
 Not move-assignable.
 
void Lock () noexcept
 Acquire the lock.
 
void Unlock () noexcept
 Release ownership.
 

Detailed Description

Mutex with owner-thread reentry.

The owning thread may call Lock() again without blocking. Another thread blocks in Lock() until the owner calls Unlock(). Unlock() from a thread that does not own the lock is a no-op.

Constructor & Destructor Documentation

◆ ThreadLock() [1/3]

StormByte::ThreadLock::ThreadLock ( )
defaultnoexcept

Unlocked lock, no owner.

◆ ThreadLock() [2/3]

StormByte::ThreadLock::ThreadLock ( const ThreadLock )
delete

Not copyable.

◆ ThreadLock() [3/3]

StormByte::ThreadLock::ThreadLock ( ThreadLock &&  )
delete

Not movable (std::mutex is not movable on Windows).

◆ ~ThreadLock()

StormByte::ThreadLock::~ThreadLock ( )
noexcept

Releases internal mutexes.

Note
The owner should Unlock() before destruction if it still holds the lock.

Member Function Documentation

◆ Lock()

void StormByte::ThreadLock::Lock ( )
noexcept

Acquire the lock.

Returns immediately if this thread already owns it. Otherwise blocks until ownership is taken.

◆ operator=() [1/2]

ThreadLock & StormByte::ThreadLock::operator= ( const ThreadLock )
delete

Not copy-assignable.

◆ operator=() [2/2]

ThreadLock & StormByte::ThreadLock::operator= ( ThreadLock &&  )
delete

Not move-assignable.

◆ Unlock()

void StormByte::ThreadLock::Unlock ( )
noexcept

Release ownership.

No-op if this thread is not the owner.


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