OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "cc/test/thread_blocker.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 |
| 9 namespace cc { |
| 10 |
| 11 ThreadBlocker::ThreadBlocker() |
| 12 : should_delay_(false), |
| 13 waiter_(false /* manual_reset */, false /* initially_signaled */) { |
| 14 } |
| 15 |
| 16 ThreadBlocker::~ThreadBlocker() { |
| 17 } |
| 18 |
| 19 void ThreadBlocker::Wait() { |
| 20 { |
| 21 base::AutoLock lock(lock_); |
| 22 if (!should_delay_) |
| 23 return; |
| 24 } |
| 25 waiter_.Wait(); |
| 26 } |
| 27 |
| 28 void ThreadBlocker::BlockWait() { |
| 29 base::AutoLock lock(lock_); |
| 30 should_delay_ = true; |
| 31 } |
| 32 |
| 33 void ThreadBlocker::UnblockWait() { |
| 34 base::AutoLock lock(lock_); |
| 35 should_delay_ = false; |
| 36 waiter_.Signal(); |
| 37 } |
| 38 |
| 39 } // namespace cc |
OLD | NEW |