CppCommon  1.0.4.1
C++ Common Library
named_condition_variable.inl
Go to the documentation of this file.
1 
9 namespace CppCommon {
10 
11 template <typename TPredicate>
12 void NamedConditionVariable::Wait(TPredicate predicate)
13 {
14  while (!predicate())
15  Wait();
16 }
17 
18 template <typename TPredicate>
19 bool 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.
UTC timestamp.
Definition: timestamp.h:248
C++ Common project definitions.
Definition: token_bucket.h:15