File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -10,32 +10,32 @@ class FooBar {
10
10
for (int i = 0 ; i < n_; ++i) {
11
11
{
12
12
unique_lock<mutex> l (m_);
13
- wait_ .wait (l, [this ]() { return !curr_; });
13
+ cv_ .wait (l, [this ]() { return !curr_; });
14
14
curr_ = !curr_;
15
15
// printFoo() outputs "foo". Do not change or remove this line.
16
16
printFoo ();
17
17
}
18
- wait_ .notify_one ();
18
+ cv_ .notify_one ();
19
19
}
20
20
}
21
21
22
22
void bar (function<void ()> printBar) {
23
23
for (int i = 0 ; i < n_; ++i) {
24
24
{
25
25
unique_lock<mutex> l (m_);
26
- wait_ .wait (l, [this ]() { return curr_; });
26
+ cv_ .wait (l, [this ]() { return curr_; });
27
27
curr_ = !curr_;
28
28
// printBar() outputs "bar". Do not change or remove this line.
29
29
printBar ();
30
30
}
31
- wait_ .notify_one ();
31
+ cv_ .notify_one ();
32
32
}
33
33
}
34
34
private:
35
35
int n_;
36
36
bool curr_ = false ;
37
37
mutex m_;
38
- condition_variable wait_ ;
38
+ condition_variable cv_ ;
39
39
};
40
40
41
41
// Time: O(n)
You can’t perform that action at this time.
0 commit comments