ost::MutexLock(3)

πŸ“¦ version 1.8.1, in ubuntu jammy

πŸ’– 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