| Index: base/condition_variable_unittest.cc
|
| ===================================================================
|
| --- base/condition_variable_unittest.cc (revision 3911)
|
| +++ base/condition_variable_unittest.cc (working copy)
|
| @@ -14,6 +14,7 @@
|
| #include "base/platform_thread.h"
|
| #include "base/scoped_ptr.h"
|
| #include "base/spin_wait.h"
|
| +#include "base/thread_collision_warner.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| namespace {
|
| @@ -76,6 +77,9 @@
|
| int shutdown_task_count() const;
|
|
|
| void thread_shutting_down();
|
| +
|
| + //----------------------------------------------------------------------------
|
| + // Worker threads can call them but not needed to acquire a lock
|
| Lock* lock();
|
|
|
| ConditionVariable* work_is_available();
|
| @@ -117,6 +121,8 @@
|
| TimeDelta worker_delay_; // Time each task takes to complete.
|
| bool allow_help_requests_; // Workers can signal more workers.
|
| bool shutdown_; // Set when threads need to terminate.
|
| +
|
| + D_DEFINE_CRITICAL_SECTION(locked_methods_);
|
| };
|
|
|
| //------------------------------------------------------------------------------
|
| @@ -474,15 +480,18 @@
|
| }
|
|
|
| int WorkQueue::GetThreadId() {
|
| + D_SCOPED_RECURSIVE_BOOK_CRITICAL_SECTION(locked_methods_);
|
| DCHECK(!EveryIdWasAllocated());
|
| return thread_started_counter_++; // Give out Unique IDs.
|
| }
|
|
|
| bool WorkQueue::EveryIdWasAllocated() const {
|
| + D_SCOPED_RECURSIVE_BOOK_CRITICAL_SECTION(locked_methods_);
|
| return thread_count_ == thread_started_counter_;
|
| }
|
|
|
| TimeDelta WorkQueue::GetAnAssignment(int thread_id) {
|
| + D_SCOPED_RECURSIVE_BOOK_CRITICAL_SECTION(locked_methods_);
|
| DCHECK_LT(0, task_count_);
|
| assignment_history_[thread_id]++;
|
| if (0 == --task_count_) {
|
| @@ -492,26 +501,32 @@
|
| }
|
|
|
| void WorkQueue::WorkIsCompleted(int thread_id) {
|
| + D_SCOPED_RECURSIVE_BOOK_CRITICAL_SECTION(locked_methods_);
|
| completion_history_[thread_id]++;
|
| }
|
|
|
| int WorkQueue::task_count() const {
|
| + D_SCOPED_RECURSIVE_BOOK_CRITICAL_SECTION(locked_methods_);
|
| return task_count_;
|
| }
|
|
|
| bool WorkQueue::allow_help_requests() const {
|
| + D_SCOPED_RECURSIVE_BOOK_CRITICAL_SECTION(locked_methods_);
|
| return allow_help_requests_;
|
| }
|
|
|
| bool WorkQueue::shutdown() const {
|
| + D_SCOPED_RECURSIVE_BOOK_CRITICAL_SECTION(locked_methods_);
|
| return shutdown_;
|
| }
|
|
|
| int WorkQueue::shutdown_task_count() const {
|
| + D_SCOPED_RECURSIVE_BOOK_CRITICAL_SECTION(locked_methods_);
|
| return shutdown_task_count_;
|
| }
|
|
|
| void WorkQueue::thread_shutting_down() {
|
| + D_SCOPED_RECURSIVE_BOOK_CRITICAL_SECTION(locked_methods_);
|
| shutdown_task_count_++;
|
| }
|
|
|
|
|