ost::Conditional(3)
π 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 classConditionaljust handle the system conditional variable, so the user is responsible for callingenterMutexandleaveMutexso 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
trueif locking the mutex was succesful otherwisefalse
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
- 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