Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(529)

Unified Diff: base/condition_variable_unittest.cc

Issue 6258: This CL is due the thread I have made on chromium-dev:... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/build/base_unittests.vcproj ('k') | base/ref_counted.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_++;
}
« no previous file with comments | « base/build/base_unittests.vcproj ('k') | base/ref_counted.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698