Go to the documentation of this file.
9 #ifndef LLDB_UTILITY_PREDICATE_H
10 #define LLDB_UTILITY_PREDICATE_H
15 #include <condition_variable>
71 std::lock_guard<std::mutex> guard(
m_mutex);
90 std::lock_guard<std::mutex> guard(
m_mutex);
91 #ifdef DB_PTHREAD_LOG_EVENTS
92 printf(
"%s (value = 0x%8.8x, broadcast_type = %i)\n", __FUNCTION__, value,
120 template <
typename C>
122 std::unique_lock<std::mutex> lock(
m_mutex);
123 auto RealCond = [&] {
return Cond(
m_value); };
128 if (
m_condition.wait_for(lock, *timeout, RealCond))
156 return WaitFor([&value](T current) {
return value == current; }, timeout) !=
184 return WaitFor([&value](T current) {
return value != current; }, timeout);
214 #ifdef DB_PTHREAD_LOG_EVENTS
215 printf(
"%s (old_value = 0x%8.8x, broadcast_type = %i) m_value = 0x%8.8x, "
217 __FUNCTION__, old_value, broadcast_type,
m_value, broadcast);
229 #endif // LLDB_UTILITY_PREDICATE_H
const Predicate & operator=(const Predicate &)=delete
std::mutex m_mutex
The mutex to use when accessing the data.
llvm::Optional< T > WaitFor(C Cond, const Timeout< std::micro > &timeout)
Wait for Cond(m_value) to be true.
Predicate(T initial_value)
Construct with initial T value initial_value.
~Predicate()=default
Destructor.
@ eBroadcastOnChange
Only broadcast if the value changes when the value is modified.
T m_value
The templatized value T that we are protecting access to.
bool WaitForValueEqualTo(T value, const Timeout< std::micro > &timeout=llvm::None)
Wait for m_value to be equal to value.
void Broadcast(T old_value, PredicateBroadcastType broadcast_type)
Broadcast if needed.
A class that represents a running process on the host machine.
@ eBroadcastAlways
Always send a broadcast when the value is modified.
T GetValue() const
Value get accessor.
llvm::Optional< T > WaitForValueNotEqualTo(T value, const Timeout< std::micro > &timeout=llvm::None)
Wait for m_value to not be equal to value.
@ eBroadcastNever
No broadcast will be sent when the value is modified.
std::condition_variable m_condition
The pthread condition variable to use for signaling that data available or changed.
Predicate()
Default constructor.
void SetValue(T value, PredicateBroadcastType broadcast_type)
Value set accessor.