ost::SemaphoreLock(3)

πŸ“¦ version 1.8.1, in ubuntu jammy

✨ 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