Storage Engine API
commit_notifier.h
Go to the documentation of this file.
1 
29 #pragma once
30 
31 #include "mongo/base/disallow_copying.h"
32 #include "mongo/stdx/condition_variable.h"
33 #include "mongo/stdx/mutex.h"
34 
35 namespace mongo {
36 
42 
43 public:
44  typedef unsigned long long When;
45 
48 
49  When now();
50 
55  void waitFor(When e);
56 
60  void awaitBeyondNow();
61 
65  void notifyAll(When e);
66 
70  unsigned nWaiting() const {
71  return _nWaiting;
72  }
73 
74 private:
75  stdx::mutex _mutex;
76  stdx::condition_variable _condition;
77 
78  When _lastDone{0};
79  When _lastReturned{0};
80  unsigned _nWaiting{0};
81 };
82 
83 } // namespace mongo
unsigned _nWaiting
Definition: commit_notifier.h:80
unsigned nWaiting() const
Returns how many threads are blocked in the waitFor/awaitBeyondNow calls.
Definition: commit_notifier.h:70
Establishes a synchronization point between threads.
Definition: commit_notifier.h:40
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
When _lastDone
Definition: commit_notifier.h:78
void waitFor(When e)
Awaits the next notifyAll() call by another thread.
Definition: commit_notifier.cpp:48
stdx::condition_variable _condition
Definition: commit_notifier.h:76
When _lastReturned
Definition: commit_notifier.h:79
~CommitNotifier()
Definition: commit_notifier.cpp:39
stdx::mutex _mutex
Definition: commit_notifier.h:75
When now()
Definition: commit_notifier.cpp:43
void notifyAll(When e)
May be called multiple times.
Definition: commit_notifier.cpp:65
unsigned long long When
Definition: commit_notifier.h:44
void awaitBeyondNow()
A bit faster than waitFor(now()).
Definition: commit_notifier.cpp:56
MONGO_DISALLOW_COPYING(CommitNotifier)