logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

ost::Conditional - A conditional variable synchcronization object for one to one and one to many signal

Author

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

GNU CommonC++                                    Sun Dec 27 2020                             ost::Conditional(3)

Constructor & Destructor Documentation

ost::Conditional::Conditional(constchar*id=NULL)
       Create an instance of a conditional.

       Parametersid name of conditional, optional for deadlock testing.

   virtualost::Conditional::~Conditional()[virtual]
       Destroy the conditional.

Detailed Description

       A conditional variable synchcronization object for one to one and one to many signal and control events
       between processes.

       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.

       Warning
           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.

       Author
           David Sugar

       conditional.

Member Function Documentation

voidost::Conditional::enterMutex(void)
       Locks the conditional's mutex for this thread. Remember that Conditional's mutex is NOT a recursive
       mutex!

       SeealsoleaveMutexvoidost::Conditional::leaveMutex(void)
       Leaving a mutex frees that mutex for use by another thread.

       SeealsoenterMutexvoidost::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.

       SeealsoenterMutexvoidost::Conditional::signal(boolbroadcast)
       Signal a conditional object and a waiting threads.

       Parametersbroadcast this signal to all waiting threads if true.

   boolost::Conditional::test(void)[inline]boolost::Conditional::tryEnterMutex(void)
       Tries to lock the conditional for the current thread. Behaves like enterMutex , except that it doesn't
       block the calling thread.

       Returns
           true if locking the mutex was succesful otherwise false

       SeealsoenterMutexleaveMutexvoidost::Conditional::unlock(void)[inline]boolost::Conditional::wait(timeout_ttimer=0,boollocked=false)
       Wait to be signaled from another thread.

       Parameterstimer time period to wait.
           locked flag if already locked the mutex.

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.

   PublicMemberFunctionsConditional (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)

See Also