CppCommon 1.0.5.0
C++ Common Library
Loading...
Searching...
No Matches
condition_variable.inl
Go to the documentation of this file.
1
9namespace CppCommon {
10
11template <typename TPredicate>
12void ConditionVariable::Wait(CriticalSection& cs, TPredicate predicate)
13{
14 while (!predicate())
15 Wait(cs);
16}
17
18template <typename TPredicate>
19bool ConditionVariable::TryWaitFor(CriticalSection& cs, const Timespan& timespan, TPredicate predicate)
20{
21 Timestamp timeout = UtcTimestamp() + timespan;
22 while (!predicate())
23 if (!TryWaitFor(cs, timeout - UtcTimestamp()))
24 return predicate();
25 return true;
26}
27
28} // namespace CppCommon
bool TryWaitFor(CriticalSection &cs, const Timespan &timespan)
Try to wait for the given timespan until condition variable is notified.
void Wait(CriticalSection &cs)
Wait until condition variable is notified.
Critical section synchronization primitive.
C++ Common project definitions.