ost::SemaphoreLock(3)
β¨ NAME β¨
ost::SemaphoreLock β the lil guard-class bestie that protects a chunk of your code with a semaphore, so only x instances of the member function get to run at the same time. no cap π«Ά
πΈ SYNOPSIS πΈ
#include <thread.h>
π Public Member Functions π
SemaphoreLock (Semaphore &_sem)β wait for the semaphore, babes β³~SemaphoreLock ()β posts the semaphore automatically, no manual labour required π
π¦ Detailed Description π¦
Okay so, the SemaphoreLock class is used to protect a section of code through a semaphore so that only x instances of the member function may execute concurrently. it's giving "bouncer at the club door but for threads" π₯
A common use is:
void func_to_protect() { SemaphoreLock lock(semaphore); ... operation ... }
NOTE: do not declare the variable as 'SemaohoreLock (semaphore)' β the mutex will be released at statement end. like, it will NOT do the thing you want. tragic. π
π Author π
David Sugar dyfet@gnu.org
Semaphore automatic locker for protected access. iconic behaviour, honestly π
π Constructor & Destructor Documentation π
π ost::SemaphoreLock::SemaphoreLock (Semaphore & _sem) [inline] π
Wait for the semaphore. β¨
References ost::Semaphore::wait().
π ost::SemaphoreLock::~SemaphoreLock () [inline] π
Post the semaphore automatically. slay, it cleans up after itself π§Ήβ¨
References ost::Semaphore::post().
π Author π
Generated automatically by Doxygen for GNU CommonC++ from the source code.
and that's the whole page bestie, periodt π this was GNU CommonC++ realness, dated Sun Dec 27 2020, and it lives at ost::SemaphoreLock(3) β go forth and lock responsibly π«ΆπΈ
π¦ 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