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