diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-21 04:55:52 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-21 04:55:52 +0000 |
commit | 20305ec6f1acf21392c2f3938a14a96f1e28e76d (patch) | |
tree | 6eff1f7be4bad1a1362d3466f0ac59292dc51acc /base/synchronization | |
parent | c6e8346b56ab61b35845aefcf9b241c654fe1253 (diff) | |
download | chromium_src-20305ec6f1acf21392c2f3938a14a96f1e28e76d.zip chromium_src-20305ec6f1acf21392c2f3938a14a96f1e28e76d.tar.gz chromium_src-20305ec6f1acf21392c2f3938a14a96f1e28e76d.tar.bz2 |
Remove obsolete base/lock.h and fix up callers to use the new header file and
the base namespace. Fix several files including lock.h unnecessarily.
BUG=none
TEST=none
Original review=http://codereview.chromium.org/6142009/
Patch by leviw@chromium.org
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72106 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/synchronization')
-rw-r--r-- | base/synchronization/condition_variable.h | 8 | ||||
-rw-r--r-- | base/synchronization/condition_variable_unittest.cc | 52 | ||||
-rw-r--r-- | base/synchronization/waitable_event.h | 4 |
3 files changed, 32 insertions, 32 deletions
diff --git a/base/synchronization/condition_variable.h b/base/synchronization/condition_variable.h index 3acd0ac..db75a49 100644 --- a/base/synchronization/condition_variable.h +++ b/base/synchronization/condition_variable.h @@ -75,7 +75,7 @@ #endif #include "base/basictypes.h" -#include "base/lock.h" +#include "base/synchronization/lock.h" namespace base { @@ -156,10 +156,10 @@ class ConditionVariable { RunState run_state_; // Private critical section for access to member data. - Lock internal_lock_; + base::Lock internal_lock_; // Lock that is acquired before calling Wait(). - Lock& user_lock_; + base::Lock& user_lock_; // Events that threads are blocked on. Event waiting_list_; @@ -176,7 +176,7 @@ class ConditionVariable { pthread_cond_t condition_; pthread_mutex_t* user_mutex_; #if !defined(NDEBUG) - Lock* user_lock_; // Needed to adjust shadow lock state on wait. + base::Lock* user_lock_; // Needed to adjust shadow lock state on wait. #endif #endif diff --git a/base/synchronization/condition_variable_unittest.cc b/base/synchronization/condition_variable_unittest.cc index 8cfe4fe..cf18320 100644 --- a/base/synchronization/condition_variable_unittest.cc +++ b/base/synchronization/condition_variable_unittest.cc @@ -8,11 +8,11 @@ #include <algorithm> #include <vector> -#include "base/synchronization/condition_variable.h" -#include "base/lock.h" #include "base/logging.h" #include "base/scoped_ptr.h" #include "base/spin_wait.h" +#include "base/synchronization/condition_variable.h" +#include "base/synchronization/lock.h" #include "base/threading/platform_thread.h" #include "base/threading/thread_collision_warner.h" #include "base/time.h" @@ -198,7 +198,7 @@ TEST_F(ConditionVariableTest, MultiThreadConsumerTest) { Time start_time; // Used to time task processing. { - AutoLock auto_lock(*queue.lock()); + base::AutoLock auto_lock(*queue.lock()); while (!queue.EveryIdWasAllocated()) queue.all_threads_have_ids()->Wait(); } @@ -209,7 +209,7 @@ TEST_F(ConditionVariableTest, MultiThreadConsumerTest) { { // Since we have no tasks yet, all threads should be waiting by now. - AutoLock auto_lock(*queue.lock()); + base::AutoLock auto_lock(*queue.lock()); EXPECT_EQ(0, queue.GetNumThreadsTakingAssignments()); EXPECT_EQ(0, queue.GetNumThreadsCompletingTasks()); EXPECT_EQ(0, queue.task_count()); @@ -232,7 +232,7 @@ TEST_F(ConditionVariableTest, MultiThreadConsumerTest) { { // Wait until all 10 work tasks have at least been assigned. - AutoLock auto_lock(*queue.lock()); + base::AutoLock auto_lock(*queue.lock()); while (queue.task_count()) queue.no_more_tasks()->Wait(); // The last of the tasks *might* still be running, but... all but one should @@ -252,7 +252,7 @@ TEST_F(ConditionVariableTest, MultiThreadConsumerTest) { { // Check that all work was done by one thread id. - AutoLock auto_lock(*queue.lock()); + base::AutoLock auto_lock(*queue.lock()); EXPECT_EQ(1, queue.GetNumThreadsTakingAssignments()); EXPECT_EQ(1, queue.GetNumThreadsCompletingTasks()); EXPECT_EQ(0, queue.task_count()); @@ -278,7 +278,7 @@ TEST_F(ConditionVariableTest, MultiThreadConsumerTest) { { // Wait until all work tasks have at least been assigned. - AutoLock auto_lock(*queue.lock()); + base::AutoLock auto_lock(*queue.lock()); while (queue.task_count()) queue.no_more_tasks()->Wait(); @@ -301,7 +301,7 @@ TEST_F(ConditionVariableTest, MultiThreadConsumerTest) { queue.SpinUntilAllThreadsAreWaiting(); { - AutoLock auto_lock(*queue.lock()); + base::AutoLock auto_lock(*queue.lock()); EXPECT_EQ(3, queue.GetNumThreadsTakingAssignments()); EXPECT_EQ(3, queue.GetNumThreadsCompletingTasks()); EXPECT_EQ(0, queue.task_count()); @@ -322,7 +322,7 @@ TEST_F(ConditionVariableTest, MultiThreadConsumerTest) { queue.SpinUntilAllThreadsAreWaiting(); { - AutoLock auto_lock(*queue.lock()); + base::AutoLock auto_lock(*queue.lock()); EXPECT_EQ(3, queue.GetNumThreadsTakingAssignments()); EXPECT_EQ(3, queue.GetNumThreadsCompletingTasks()); EXPECT_EQ(0, queue.task_count()); @@ -343,7 +343,7 @@ TEST_F(ConditionVariableTest, MultiThreadConsumerTest) { queue.SpinUntilAllThreadsAreWaiting(); // Should take about 60 ms. { - AutoLock auto_lock(*queue.lock()); + base::AutoLock auto_lock(*queue.lock()); EXPECT_EQ(10, queue.GetNumThreadsTakingAssignments()); EXPECT_EQ(10, queue.GetNumThreadsCompletingTasks()); EXPECT_EQ(0, queue.task_count()); @@ -362,7 +362,7 @@ TEST_F(ConditionVariableTest, MultiThreadConsumerTest) { queue.SpinUntilAllThreadsAreWaiting(); // Should take about 60 ms. { - AutoLock auto_lock(*queue.lock()); + base::AutoLock auto_lock(*queue.lock()); EXPECT_EQ(10, queue.GetNumThreadsTakingAssignments()); EXPECT_EQ(10, queue.GetNumThreadsCompletingTasks()); EXPECT_EQ(0, queue.task_count()); @@ -381,11 +381,11 @@ TEST_F(ConditionVariableTest, LargeFastTaskTest) { WorkQueue queue(kThreadCount); // Start the threads. Lock private_lock; // Used locally for master to wait. - AutoLock private_held_lock(private_lock); + base::AutoLock private_held_lock(private_lock); ConditionVariable private_cv(&private_lock); { - AutoLock auto_lock(*queue.lock()); + base::AutoLock auto_lock(*queue.lock()); while (!queue.EveryIdWasAllocated()) queue.all_threads_have_ids()->Wait(); } @@ -395,7 +395,7 @@ TEST_F(ConditionVariableTest, LargeFastTaskTest) { { // Since we have no tasks, all threads should be waiting by now. - AutoLock auto_lock(*queue.lock()); + base::AutoLock auto_lock(*queue.lock()); EXPECT_EQ(0, queue.GetNumThreadsTakingAssignments()); EXPECT_EQ(0, queue.GetNumThreadsCompletingTasks()); EXPECT_EQ(0, queue.task_count()); @@ -412,7 +412,7 @@ TEST_F(ConditionVariableTest, LargeFastTaskTest) { queue.work_is_available()->Broadcast(); // Start up all threads. // Wait until we've handed out all tasks. { - AutoLock auto_lock(*queue.lock()); + base::AutoLock auto_lock(*queue.lock()); while (queue.task_count() != 0) queue.no_more_tasks()->Wait(); } @@ -423,7 +423,7 @@ TEST_F(ConditionVariableTest, LargeFastTaskTest) { { // With Broadcast(), every thread should have participated. // but with racing.. they may not all have done equal numbers of tasks. - AutoLock auto_lock(*queue.lock()); + base::AutoLock auto_lock(*queue.lock()); EXPECT_EQ(kThreadCount, queue.GetNumThreadsTakingAssignments()); EXPECT_EQ(kThreadCount, queue.GetNumThreadsCompletingTasks()); EXPECT_EQ(0, queue.task_count()); @@ -440,7 +440,7 @@ TEST_F(ConditionVariableTest, LargeFastTaskTest) { // Wait until we've handed out all tasks { - AutoLock auto_lock(*queue.lock()); + base::AutoLock auto_lock(*queue.lock()); while (queue.task_count() != 0) queue.no_more_tasks()->Wait(); } @@ -451,7 +451,7 @@ TEST_F(ConditionVariableTest, LargeFastTaskTest) { { // With Signal(), every thread should have participated. // but with racing.. they may not all have done four tasks. - AutoLock auto_lock(*queue.lock()); + base::AutoLock auto_lock(*queue.lock()); EXPECT_EQ(kThreadCount, queue.GetNumThreadsTakingAssignments()); EXPECT_EQ(kThreadCount, queue.GetNumThreadsCompletingTasks()); EXPECT_EQ(0, queue.task_count()); @@ -500,7 +500,7 @@ WorkQueue::WorkQueue(int thread_count) WorkQueue::~WorkQueue() { { - AutoLock auto_lock(lock_); + base::AutoLock auto_lock(lock_); SetShutdown(); } work_is_available_.Broadcast(); // Tell them all to terminate. @@ -558,7 +558,7 @@ bool WorkQueue::shutdown() const { // lock already acquired. bool WorkQueue::ThreadSafeCheckShutdown(int thread_count) { bool all_shutdown; - AutoLock auto_lock(lock_); + base::AutoLock auto_lock(lock_); { // Declare in scope so DFAKE is guranteed to be destroyed before AutoLock. DFAKE_SCOPED_RECURSIVE_LOCK(locked_methods_); @@ -657,7 +657,7 @@ void WorkQueue::SetShutdown() { void WorkQueue::SpinUntilAllThreadsAreWaiting() { while (true) { { - AutoLock auto_lock(lock_); + base::AutoLock auto_lock(lock_); if (waiting_thread_count_ == thread_count_) break; } @@ -668,7 +668,7 @@ void WorkQueue::SpinUntilAllThreadsAreWaiting() { void WorkQueue::SpinUntilTaskCountLessThan(int task_count) { while (true) { { - AutoLock auto_lock(lock_); + base::AutoLock auto_lock(lock_); if (task_count_ < task_count) break; } @@ -698,7 +698,7 @@ void WorkQueue::SpinUntilTaskCountLessThan(int task_count) { void WorkQueue::ThreadMain() { int thread_id; { - AutoLock auto_lock(lock_); + base::AutoLock auto_lock(lock_); thread_id = GetThreadId(); if (EveryIdWasAllocated()) all_threads_have_ids()->Signal(); // Tell creator we're ready. @@ -709,7 +709,7 @@ void WorkQueue::ThreadMain() { TimeDelta work_time; bool could_use_help; { - AutoLock auto_lock(lock_); + base::AutoLock auto_lock(lock_); while (0 == task_count() && !shutdown()) { ++waiting_thread_count_; work_is_available()->Wait(); @@ -732,13 +732,13 @@ void WorkQueue::ThreadMain() { if (work_time > TimeDelta::FromMilliseconds(0)) { // We could just sleep(), but we'll instead further exercise the // condition variable class, and do a timed wait. - AutoLock auto_lock(private_lock); + base::AutoLock auto_lock(private_lock); ConditionVariable private_cv(&private_lock); private_cv.TimedWait(work_time); // Unsynchronized waiting. } { - AutoLock auto_lock(lock_); + base::AutoLock auto_lock(lock_); // Send notification that we completed our "work." WorkIsCompleted(thread_id); } diff --git a/base/synchronization/waitable_event.h b/base/synchronization/waitable_event.h index 01b5987..9f357d1 100644 --- a/base/synchronization/waitable_event.h +++ b/base/synchronization/waitable_event.h @@ -15,8 +15,8 @@ #if defined(OS_POSIX) #include <list> #include <utility> -#include "base/lock.h" #include "base/ref_counted.h" +#include "base/synchronization/lock.h" #endif namespace base { @@ -149,7 +149,7 @@ class WaitableEvent { bool Dequeue(Waiter* waiter, void* tag); - Lock lock_; + base::Lock lock_; const bool manual_reset_; bool signaled_; std::list<Waiter*> waiters_; |