ost::Conditional(3)

πŸ“¦ version 1.8.1, in ubuntu jammy

πŸ’– ost::Conditional(3) πŸ’–

okay bestie, welcome to the Library Functions Manual section, we're talking about ost::Conditional(3) and honestly? it's giving thread-synchronization icon behavior. sit down, grab a boba, let's go πŸ§‹βœ¨


✨ NAME ✨

ost::Conditional β€” a conditional variable synchcronization object for one to one and one to many signal and control events between processes. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <thread.h>

Inherited by ost::Buffer.

🌸 Public Member Functions 🌸

  • Conditional (const char *id=NULL) β€” Create an instance of a conditional.
  • virtual ~Conditional () β€” Destroy the conditional.
  • void signal (bool broadcast) β€” Signal a conditional object and a waiting threads.
  • bool wait (timeout_t timer=0, bool locked=false) β€” Wait to be signaled from another thread.
  • void enterMutex (void) β€” Locks the conditional's mutex for this thread.
  • void lock (void) β€” In the future we will use lock in place of enterMutex since the conditional composite is not a recursive mutex, and hence using enterMutex may cause confusion in expectation with the behavior of the Mutex class.
  • bool tryEnterMutex (void) β€” Tries to lock the conditional for the current thread.
  • bool test (void)
  • void leaveMutex (void) β€” Leaving a mutex frees that mutex for use by another thread.
  • void unlock (void)

πŸ‘‘ Detailed Description πŸ‘‘

A conditional variable synchcronization object for one to one and one to many signal and control events between processes. fr fr. πŸ’œ

Conditional variables may wait for and receive signals to notify when to resume or perform operations. Multiple waiting threads may be woken with a broadcast signal. so like, one text, everybody sees it. main character group chat energy. 🌈

Warning ⚠️ okay this part is IMPORTANT bestie, no cap: While this class inherits from Mutex, the methods of the class Conditional just handle the system conditional variable, so the user is responsible for calling enterMutex and leaveMutex so as to avoid race conditions. Another thing to note is that if you have several threads waiting on one condition, not uncommon in thread pools, each thread must take care to manually unlock the mutex if cancellation occurs. Otherwise the first thread cancelled will deadlock the rest of the thread. πŸ’€ literally deadlock. not the cute kind.

🌟 Author 🌟

David Sugar

conditional. (yes that's the whole line, we love a minimal queen πŸŽ€)


πŸŽ€ Constructor & Destructor Documentation πŸŽ€

ost::Conditional::Conditional (const char * id = NULL)

Create an instance of a conditional. new bestie just dropped ✨

Parameters

  • id β€” name of conditional, optional for deadlock testing.

virtual ost::Conditional::~Conditional () [virtual]

Destroy the conditional. she's done, she's logging off, she's leaving the group chat πŸ¦‹


πŸ’… Member Function Documentation πŸ’…

void ost::Conditional::enterMutex (void)

Locks the conditional's mutex for this thread. Remember that Conditional's mutex is NOT a recursive mutex! 🚨 like, do not assume it'll re-enter for you, it will not, it's not that kind of girl.

See also: leaveMutex

void ost::Conditional::leaveMutex (void)

Leaving a mutex frees that mutex for use by another thread. sharing is caring 🫢

See also: enterMutex

void ost::Conditional::lock (void) [inline]

In the future we will use lock in place of enterMutex since the conditional composite is not a recursive mutex, and hence using enterMutex may cause confusion in expectation with the behavior of the Mutex class. (they're literally telling us the naming is a lil confusing, and honestly? respect for the honesty πŸ™ˆ)

See also: enterMutex

void ost::Conditional::signal (bool broadcast)

Signal a conditional object and a waiting threads. wake up babes, it's time β˜€οΈ

Parameters

  • broadcast β€” this signal to all waiting threads if true.

bool ost::Conditional::test (void) [inline]

(no description, she's mysterious, she's lowkey, we move 🧚)

bool ost::Conditional::tryEnterMutex (void)

Tries to lock the conditional for the current thread. Behaves like enterMutex, except that it doesn't block the calling thread. the "u up?" of mutex locking β€” if she doesn't answer, you just keep it moving πŸ’…

Returns

  • true if locking the mutex was succesful otherwise false

See also: enterMutex

See also: leaveMutex

void ost::Conditional::unlock (void) [inline]

(no description again β€” iconic silent type πŸŽ€)

bool ost::Conditional::wait (timeout_t timer = 0, bool locked = false)

Wait to be signaled from another thread. sitting there, phone in hand, waiting for the notification πŸ“±

Parameters

  • timer β€” time period to wait.
  • locked β€” flag if already locked the mutex.

πŸ’– Author πŸ’–

Generated automatically by Doxygen for GNU CommonC++ from the source code.


and that's the whole page bestie, you ate that πŸ“ mwah πŸ’‹

sign-off time: this lil masterpiece came from GNU CommonC++, dated Sun Dec 27 2020, and it's filed under ost::Conditional(3). periodt. πŸ‘‘βœ¨

πŸ“¦ where this page comes from