Welcome to mirror list, hosted at ThFree Co, Russian Federation.

condition.hpp « base - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 331aa9f4f8a3f1ac69015e5b04828d75d6a8ea42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once

namespace threads
{
  namespace impl
  {
    class ConditionImpl;
  }

  /// Implements mutexed condition semantics
  class Condition
  {
    impl::ConditionImpl * m_pImpl;

    Condition(Condition const &);
    Condition & operator=(Condition const &);

  public:        
    Condition();
    ~Condition();

    void Signal(bool broadcast = false);
    void Wait();
    /// @return whether we are exiting by timeout.
    bool Wait(unsigned ms);

    void Lock();
    bool TryLock();
    void Unlock();
  };

  /// ScopeGuard wrapper around mutex
  class ConditionGuard
  {
  private:
    Condition & m_Condition;
  public:
    ConditionGuard(Condition & condition);
    ~ConditionGuard();
    void Wait(unsigned ms = -1);
    void Signal(bool broadcast = false);
  };
}