1 //===-- Condition.h ---------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_DBCondition_h_
11 #define liblldb_DBCondition_h_
12 #if defined(__cplusplus)
15 #include "lldb/lldb-types.h"
16 #include "lldb/Host/Mutex.h"
18 namespace lldb_private {
22 //----------------------------------------------------------------------
23 /// @class Condition Condition.h "lldb/Host/Condition.h"
24 /// @brief A C++ wrapper class for pthread condition variables.
26 /// A class that wraps up a pthread condition (pthread_cond_t). The
27 /// class will create a pthread condition when an instance is
28 /// constructed, and detroy it when it is destructed. It also provides
29 /// access to the standard pthread condition calls.
30 //----------------------------------------------------------------------
35 //------------------------------------------------------------------
36 /// Default constructor
38 /// The default constructor will initialize a new pthread condition
39 /// and maintain the condition in the object state.
40 //------------------------------------------------------------------
43 //------------------------------------------------------------------
46 /// Destroys the pthread condition that the object owns.
47 //------------------------------------------------------------------
50 //------------------------------------------------------------------
51 /// Unblock all threads waiting for a condition variable
54 /// The return value from \c pthread_cond_broadcast()
55 //------------------------------------------------------------------
59 //------------------------------------------------------------------
60 /// Unblocks one thread waiting for the condition variable
63 /// The return value from \c pthread_cond_signal()
64 //------------------------------------------------------------------
68 //------------------------------------------------------------------
69 /// Wait for the condition variable to be signaled.
71 /// The Wait() function atomically blocks the current thread
72 /// waiting on this object's condition variable, and unblocks
73 /// \a mutex. The waiting thread unblocks only after another thread
74 /// signals or broadcasts this object's condition variable.
76 /// If \a abstime is non-NULL, this function will return when the
77 /// system time reaches the time specified in \a abstime if the
78 /// condition variable doesn't get unblocked. If \a abstime is NULL
79 /// this function will wait for an infinite amount of time for the
80 /// condition variable to be unblocked.
82 /// The current thread re-acquires the lock on \a mutex following
86 /// The mutex to use in the \c pthread_cond_timedwait() or
87 /// \c pthread_cond_wait() calls.
89 /// @param[in] abstime
90 /// An absolute time at which to stop waiting if non-NULL, else
91 /// wait an infinite amount of time for the condition variable
94 /// @param[out] timed_out
95 /// If not NULL, will be set to true if the wait timed out, and
98 /// @see Condition::Broadcast()
99 /// @see Condition::Signal()
100 //------------------------------------------------------------------
102 Wait (Mutex &mutex, const TimeValue *abstime = NULL, bool *timed_out = NULL);
105 //------------------------------------------------------------------
107 //------------------------------------------------------------------
108 lldb::condition_t m_condition; ///< The condition variable.
110 //------------------------------------------------------------------
111 /// Get accessor to the pthread condition object.
114 /// A pointer to the condition variable owned by this object.
115 //------------------------------------------------------------------
120 } // namespace lldb_private
122 #endif // #if defined(__cplusplus)