ost::MutexLock(3)
π ost::MutexLock β from the ost library (manual section 3, Library Functions Manual)
okay bestie, gather round, because this one is a lil class that does a BIG job π«Ά
β¨ NAME β¨
ost::MutexLock β the class that locks down a section of your code so that, at any given moment, only one single thread can run the protected operation. periodt. π
πΈ SYNOPSIS πΈ
#include <thread.h>
π Public Member Functions
MutexLock (Mutex &_mutex)β grab that mutex, bestie, it's yours now β¨~MutexLock ()β gives the mutex back automatically when you're done, no take-backs π
π¦ Detailed Description π¦
okay so, the MutexLock class is used to protect a section of code so that at any given time only a single thread can perform the protected operation. that's it, that's the whole vibe check and it passes.
it uses Mutex to protect the operation. using this class is usefull and exception safe. lowkey the best part: the mutex that has been locked is automatically released when the function call stack falls out of scope, so one doesnt have to remember to unlock the mutex at each function return. no more forgotten unlocks, we don't do that here πβ¨
a common use is
void func_to_protect() { MutexLock lock(mutex); ... operation ... }
NOTE: do not declare variable as 'MutexLock (mutex)', the mutex will be released at statement end. π that's the classic trap, bestie, don't fall for it.
π Author
Frediano Ziglio freddy77@angelfire.com β iconic, we love a credited legend π
Mutex automatic locker for protected access.
π§ Constructor & Destructor Documentation π§
β ost::MutexLock::MutexLock (Mutex & _mutex) [inline]
Acquire the mutex. it's giving main character energy, it's taking the lock and it is not asking permission π₯
Parameters
_mutexβ reference to mutex to aquire.
References ost::Mutex::enterMutex().
β ost::MutexLock::~MutexLock () [inline]
Release the mutex automatically. the way that it cleans up after itself without you even asking? obsessed π
References ost::Mutex::leaveMutex().
π Author π
Generated automatically by Doxygen for GNU CommonC++ from the source code.
and that's the whole page, bestie π this manual page was brought to you by GNU CommonC++, dated Sun Dec 27 2020, and it lives at ost::MutexLock(3) β go forth and lock responsibly, no cap ππ¦πΈ
π¦ where this page comes from
- ubuntu jammy: libcommoncpp2-doc 1.8.1-10
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms