summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/at_exit.h4
-rw-r--r--base/crypto/capi_util.cc8
-rw-r--r--base/debug/stack_trace_win.cc6
-rw-r--r--base/debug/trace_event.h4
-rw-r--r--base/i18n/file_util_icu.cc4
-rw-r--r--base/linux_util.cc8
-rw-r--r--base/lock.h18
-rw-r--r--base/message_loop.cc4
-rw-r--r--base/message_loop.h4
-rw-r--r--base/message_loop_proxy_impl.h4
-rw-r--r--base/metrics/field_trial.h4
-rw-r--r--base/metrics/stats_table.h4
-rw-r--r--base/nss_util.cc2
-rw-r--r--base/observer_list_threadsafe.h12
-rw-r--r--base/openssl_util.cc6
-rw-r--r--base/path_service.cc18
-rw-r--r--base/synchronization/condition_variable.h8
-rw-r--r--base/synchronization/condition_variable_unittest.cc52
-rw-r--r--base/synchronization/waitable_event.h4
-rw-r--r--base/third_party/dmg_fp/dtoa_wrapper.cc4
-rw-r--r--base/threading/simple_thread.h4
-rw-r--r--base/threading/thread_checker.h4
-rw-r--r--base/threading/thread_collision_warner_unittest.cc24
-rw-r--r--base/threading/worker_pool_posix_unittest.cc14
-rw-r--r--base/time_win.cc8
-rw-r--r--base/tracked_objects.cc28
-rw-r--r--base/tracked_objects.h8
27 files changed, 125 insertions, 143 deletions
diff --git a/base/at_exit.h b/base/at_exit.h
index 35c96b9..15dcfc8 100644
--- a/base/at_exit.h
+++ b/base/at_exit.h
@@ -9,7 +9,7 @@
#include <stack>
#include "base/basictypes.h"
-#include "base/lock.h"
+#include "base/synchronization/lock.h"
namespace base {
@@ -60,7 +60,7 @@ class AtExitManager {
void* param_;
};
- Lock lock_;
+ base::Lock lock_;
std::stack<CallbackAndParam> stack_;
AtExitManager* next_manager_; // Stack of managers to allow shadowing.
diff --git a/base/crypto/capi_util.cc b/base/crypto/capi_util.cc
index cf47a50..ef57a3c 100644
--- a/base/crypto/capi_util.cc
+++ b/base/crypto/capi_util.cc
@@ -5,8 +5,8 @@
#include "base/crypto/capi_util.h"
#include "base/basictypes.h"
-#include "base/lock.h"
#include "base/singleton.h"
+#include "base/synchronization/lock.h"
namespace {
@@ -18,7 +18,7 @@ class CAPIUtilSingleton {
// Returns a lock to guard calls to CryptAcquireContext with
// CRYPT_DELETEKEYSET or CRYPT_NEWKEYSET.
- Lock& acquire_context_lock() {
+ base::Lock& acquire_context_lock() {
return acquire_context_lock_;
}
@@ -28,7 +28,7 @@ class CAPIUtilSingleton {
CAPIUtilSingleton() {}
- Lock acquire_context_lock_;
+ base::Lock acquire_context_lock_;
DISALLOW_COPY_AND_ASSIGN(CAPIUtilSingleton);
};
@@ -43,7 +43,7 @@ BOOL CryptAcquireContextLocked(HCRYPTPROV* prov,
DWORD prov_type,
DWORD flags)
{
- AutoLock lock(CAPIUtilSingleton::GetInstance()->acquire_context_lock());
+ base::AutoLock lock(CAPIUtilSingleton::GetInstance()->acquire_context_lock());
return CryptAcquireContext(prov, container, provider, prov_type, flags);
}
diff --git a/base/debug/stack_trace_win.cc b/base/debug/stack_trace_win.cc
index 6f4ad02..510d35b 100644
--- a/base/debug/stack_trace_win.cc
+++ b/base/debug/stack_trace_win.cc
@@ -10,9 +10,9 @@
#include <iostream>
#include "base/basictypes.h"
-#include "base/lock.h"
#include "base/logging.h"
#include "base/singleton.h"
+#include "base/synchronization/lock.h"
namespace base {
namespace debug {
@@ -59,7 +59,7 @@ class SymbolContext {
void OutputTraceToStream(const void* const* trace,
int count,
std::ostream* os) {
- AutoLock lock(lock_);
+ base::AutoLock lock(lock_);
for (size_t i = 0; (i < count) && os->good(); ++i) {
const int kMaxNameLength = 256;
@@ -129,7 +129,7 @@ class SymbolContext {
}
DWORD init_error_;
- Lock lock_;
+ base::Lock lock_;
DISALLOW_COPY_AND_ASSIGN(SymbolContext);
};
diff --git a/base/debug/trace_event.h b/base/debug/trace_event.h
index 160bbc8..3eb1f49a 100644
--- a/base/debug/trace_event.h
+++ b/base/debug/trace_event.h
@@ -31,9 +31,9 @@
#include <string>
-#include "base/lock.h"
#include "base/scoped_ptr.h"
#include "base/singleton.h"
+#include "base/synchronization/lock.h"
#include "base/time.h"
#include "base/timer.h"
@@ -135,7 +135,7 @@ class TraceLog {
bool enabled_;
FILE* log_file_;
- Lock file_lock_;
+ base::Lock file_lock_;
TimeTicks trace_start_time_;
scoped_ptr<base::ProcessMetrics> process_metrics_;
RepeatingTimer<TraceLog> timer_;
diff --git a/base/i18n/file_util_icu.cc b/base/i18n/file_util_icu.cc
index 34eefac..ba69da0 100644
--- a/base/i18n/file_util_icu.cc
+++ b/base/i18n/file_util_icu.cc
@@ -90,7 +90,7 @@ class LocaleAwareComparator {
int Compare(const string16& a, const string16& b) {
// We are not sure if Collator::compare is thread-safe.
// Use an AutoLock just in case.
- AutoLock auto_lock(lock_);
+ base::AutoLock auto_lock(lock_);
UErrorCode error_code = U_ZERO_ERROR;
UCollationResult result = collator_->compare(
@@ -120,7 +120,7 @@ class LocaleAwareComparator {
}
scoped_ptr<icu::Collator> collator_;
- Lock lock_;
+ base::Lock lock_;
friend struct DefaultSingletonTraits<LocaleAwareComparator>;
DISALLOW_COPY_AND_ASSIGN(LocaleAwareComparator);
diff --git a/base/linux_util.cc b/base/linux_util.cc
index e1f7275..4e7cc5c 100644
--- a/base/linux_util.cc
+++ b/base/linux_util.cc
@@ -17,12 +17,12 @@
#include "base/command_line.h"
#include "base/file_util.h"
-#include "base/lock.h"
#include "base/path_service.h"
#include "base/process_util.h"
#include "base/singleton.h"
#include "base/scoped_ptr.h"
#include "base/string_util.h"
+#include "base/synchronization/lock.h"
namespace {
@@ -51,7 +51,7 @@ class LinuxDistroHelper {
// we automatically move to STATE_CHECK_STARTED so nobody else will
// do the check.
LinuxDistroState State() {
- AutoLock scoped_lock(lock_);
+ base::AutoLock scoped_lock(lock_);
if (STATE_DID_NOT_CHECK == state_) {
state_ = STATE_CHECK_STARTED;
return STATE_DID_NOT_CHECK;
@@ -61,13 +61,13 @@ class LinuxDistroHelper {
// Indicate the check finished, move to STATE_CHECK_FINISHED.
void CheckFinished() {
- AutoLock scoped_lock(lock_);
+ base::AutoLock scoped_lock(lock_);
DCHECK(state_ == STATE_CHECK_STARTED);
state_ = STATE_CHECK_FINISHED;
}
private:
- Lock lock_;
+ base::Lock lock_;
LinuxDistroState state_;
};
#endif // if defined(OS_LINUX)
diff --git a/base/lock.h b/base/lock.h
deleted file mode 100644
index 7c90d86..0000000
--- a/base/lock.h
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_LOCK_H_
-#define BASE_LOCK_H_
-#pragma once
-
-// This is a temporary forwarding file so not every user of lock needs to
-// be updated at once.
-// TODO(brettw) remove this and fix everybody up to using the new location.
-#include "base/synchronization/lock.h"
-
-using base::AutoLock;
-using base::AutoUnlock;
-using base::Lock;
-
-#endif // BASE_LOCK_H_
diff --git a/base/message_loop.cc b/base/message_loop.cc
index e74331a..518a0fd 100644
--- a/base/message_loop.cc
+++ b/base/message_loop.cc
@@ -394,7 +394,7 @@ void MessageLoop::ReloadWorkQueue() {
// Acquire all we can from the inter-thread queue with one lock acquisition.
{
- AutoLock lock(incoming_queue_lock_);
+ base::AutoLock lock(incoming_queue_lock_);
if (incoming_queue_.empty())
return;
incoming_queue_.Swap(&work_queue_); // Constant time
@@ -495,7 +495,7 @@ void MessageLoop::PostTask_Helper(
scoped_refptr<base::MessagePump> pump;
{
- AutoLock locked(incoming_queue_lock_);
+ base::AutoLock locked(incoming_queue_lock_);
bool was_empty = incoming_queue_.empty();
incoming_queue_.push(pending_task);
diff --git a/base/message_loop.h b/base/message_loop.h
index d5093a9..7a3af6e 100644
--- a/base/message_loop.h
+++ b/base/message_loop.h
@@ -10,10 +10,10 @@
#include <string>
#include "base/basictypes.h"
-#include "base/lock.h"
#include "base/message_pump.h"
#include "base/observer_list.h"
#include "base/ref_counted.h"
+#include "base/synchronization/lock.h"
#include "base/task.h"
#if defined(OS_WIN)
@@ -466,7 +466,7 @@ class MessageLoop : public base::MessagePump::Delegate {
// will be handled by the TimerManager.
TaskQueue incoming_queue_;
// Protect access to incoming_queue_.
- Lock incoming_queue_lock_;
+ base::Lock incoming_queue_lock_;
RunState* state_;
diff --git a/base/message_loop_proxy_impl.h b/base/message_loop_proxy_impl.h
index 44ab2ea..03e0271 100644
--- a/base/message_loop_proxy_impl.h
+++ b/base/message_loop_proxy_impl.h
@@ -6,9 +6,9 @@
#define BASE_MESSAGE_LOOP_PROXY_IMPL_H_
#pragma once
-#include "base/lock.h"
#include "base/message_loop.h"
#include "base/message_loop_proxy.h"
+#include "base/synchronization/lock.h"
namespace base {
@@ -50,7 +50,7 @@ class MessageLoopProxyImpl : public MessageLoopProxy,
friend class MessageLoopProxy;
// The lock that protects access to target_message_loop_.
- mutable Lock message_loop_lock_;
+ mutable base::Lock message_loop_lock_;
MessageLoop* target_message_loop_;
DISALLOW_COPY_AND_ASSIGN(MessageLoopProxyImpl);
diff --git a/base/metrics/field_trial.h b/base/metrics/field_trial.h
index 077a88c..ec3a483 100644
--- a/base/metrics/field_trial.h
+++ b/base/metrics/field_trial.h
@@ -67,8 +67,8 @@
#include <string>
#include "base/gtest_prod_util.h"
-#include "base/lock.h"
#include "base/ref_counted.h"
+#include "base/synchronization/lock.h"
#include "base/time.h"
namespace base {
@@ -271,7 +271,7 @@ class FieldTrialList {
TimeTicks application_start_time_;
// Lock for access to registered_.
- Lock lock_;
+ base::Lock lock_;
RegistrationList registered_;
DISALLOW_COPY_AND_ASSIGN(FieldTrialList);
diff --git a/base/metrics/stats_table.h b/base/metrics/stats_table.h
index 32b22eb..aaf8062 100644
--- a/base/metrics/stats_table.h
+++ b/base/metrics/stats_table.h
@@ -25,7 +25,7 @@
#include "base/basictypes.h"
#include "base/hash_tables.h"
-#include "base/lock.h"
+#include "base/synchronization/lock.h"
#include "base/threading/thread_local_storage.h"
namespace base {
@@ -175,7 +175,7 @@ class StatsTable {
Private* impl_;
// The counters_lock_ protects the counters_ hash table.
- Lock counters_lock_;
+ base::Lock counters_lock_;
// The counters_ hash map is an in-memory hash of the counters.
// It is used for quick lookup of counters, but is cannot be used
diff --git a/base/nss_util.cc b/base/nss_util.cc
index 384cc0d..8e250c4 100644
--- a/base/nss_util.cc
+++ b/base/nss_util.cc
@@ -31,8 +31,8 @@
#if defined(USE_NSS)
#include "base/crypto/crypto_module_blocking_password_delegate.h"
#include "base/environment.h"
-#include "base/lock.h"
#include "base/scoped_ptr.h"
+#include "base/synchronization/lock.h"
#endif // defined(USE_NSS)
namespace base {
diff --git a/base/observer_list_threadsafe.h b/base/observer_list_threadsafe.h
index ecdad90..47a662e 100644
--- a/base/observer_list_threadsafe.h
+++ b/base/observer_list_threadsafe.h
@@ -93,7 +93,7 @@ class ObserverListThreadSafe
if (!loop)
return; // Some unittests may access this without a message loop.
{
- AutoLock lock(list_lock_);
+ base::AutoLock lock(list_lock_);
if (observer_lists_.find(loop) == observer_lists_.end())
observer_lists_[loop] = new ObserverList<ObserverType>(type_);
list = observer_lists_[loop];
@@ -112,7 +112,7 @@ class ObserverListThreadSafe
if (!loop)
return; // On shutdown, it is possible that current() is already null.
{
- AutoLock lock(list_lock_);
+ base::AutoLock lock(list_lock_);
list = observer_lists_[loop];
if (!list) {
NOTREACHED() << "RemoveObserver called on for unknown thread";
@@ -165,7 +165,7 @@ class ObserverListThreadSafe
template <class Method, class Params>
void Notify(const UnboundMethod<ObserverType, Method, Params>& method) {
- AutoLock lock(list_lock_);
+ base::AutoLock lock(list_lock_);
typename ObserversListMap::iterator it;
for (it = observer_lists_.begin(); it != observer_lists_.end(); ++it) {
MessageLoop* loop = (*it).first;
@@ -187,7 +187,7 @@ class ObserverListThreadSafe
// Check that this list still needs notifications.
{
- AutoLock lock(list_lock_);
+ base::AutoLock lock(list_lock_);
typename ObserversListMap::iterator it =
observer_lists_.find(MessageLoop::current());
@@ -209,7 +209,7 @@ class ObserverListThreadSafe
// If there are no more observers on the list, we can now delete it.
if (list->size() == 0) {
{
- AutoLock lock(list_lock_);
+ base::AutoLock lock(list_lock_);
// Remove |list| if it's not already removed.
// This can happen if multiple observers got removed in a notification.
// See http://crbug.com/55725.
@@ -225,7 +225,7 @@ class ObserverListThreadSafe
typedef std::map<MessageLoop*, ObserverList<ObserverType>*> ObserversListMap;
// These are marked mutable to facilitate having NotifyAll be const.
- Lock list_lock_; // Protects the observer_lists_.
+ base::Lock list_lock_; // Protects the observer_lists_.
ObserversListMap observer_lists_;
const NotificationType type_;
diff --git a/base/openssl_util.cc b/base/openssl_util.cc
index bc174fa..931485a 100644
--- a/base/openssl_util.cc
+++ b/base/openssl_util.cc
@@ -7,11 +7,11 @@
#include <openssl/err.h>
#include <openssl/ssl.h>
-#include "base/lock.h"
#include "base/logging.h"
#include "base/scoped_vector.h"
#include "base/singleton.h"
#include "base/string_piece.h"
+#include "base/synchronization/lock.h"
namespace base {
@@ -46,7 +46,7 @@ class OpenSSLInitSingleton {
int num_locks = CRYPTO_num_locks();
locks_.reserve(num_locks);
for (int i = 0; i < num_locks; ++i)
- locks_.push_back(new Lock());
+ locks_.push_back(new base::Lock());
CRYPTO_set_locking_callback(LockingCallback);
CRYPTO_set_id_callback(CurrentThreadId);
}
@@ -70,7 +70,7 @@ class OpenSSLInitSingleton {
}
// These locks are used and managed by OpenSSL via LockingCallback().
- ScopedVector<Lock> locks_;
+ ScopedVector<base::Lock> locks_;
DISALLOW_COPY_AND_ASSIGN(OpenSSLInitSingleton);
};
diff --git a/base/path_service.cc b/base/path_service.cc
index 56ce5fa..117feb5 100644
--- a/base/path_service.cc
+++ b/base/path_service.cc
@@ -14,8 +14,8 @@
#include "base/file_util.h"
#include "base/hash_tables.h"
#include "base/lazy_instance.h"
-#include "base/lock.h"
#include "base/logging.h"
+#include "base/synchronization/lock.h"
namespace base {
bool PathProvider(int key, FilePath* result);
@@ -92,9 +92,9 @@ static Provider base_provider_posix = {
struct PathData {
- Lock lock;
- PathMap cache; // Cache mappings from path key to path value.
- PathMap overrides; // Track path overrides.
+ base::Lock lock;
+ PathMap cache; // Cache mappings from path key to path value.
+ PathMap overrides; // Track path overrides.
Provider* providers; // Linked list of path service providers.
PathData() {
@@ -130,7 +130,7 @@ static PathData* GetPathData() {
// static
bool PathService::GetFromCache(int key, FilePath* result) {
PathData* path_data = GetPathData();
- AutoLock scoped_lock(path_data->lock);
+ base::AutoLock scoped_lock(path_data->lock);
// check for a cached version
PathMap::const_iterator it = path_data->cache.find(key);
@@ -144,7 +144,7 @@ bool PathService::GetFromCache(int key, FilePath* result) {
// static
bool PathService::GetFromOverrides(int key, FilePath* result) {
PathData* path_data = GetPathData();
- AutoLock scoped_lock(path_data->lock);
+ base::AutoLock scoped_lock(path_data->lock);
// check for an overriden version.
PathMap::const_iterator it = path_data->overrides.find(key);
@@ -158,7 +158,7 @@ bool PathService::GetFromOverrides(int key, FilePath* result) {
// static
void PathService::AddToCache(int key, const FilePath& path) {
PathData* path_data = GetPathData();
- AutoLock scoped_lock(path_data->lock);
+ base::AutoLock scoped_lock(path_data->lock);
// Save the computed path in our cache.
path_data->cache[key] = path;
}
@@ -225,7 +225,7 @@ bool PathService::Override(int key, const FilePath& path) {
if (!file_util::AbsolutePath(&file_path))
return false;
- AutoLock scoped_lock(path_data->lock);
+ base::AutoLock scoped_lock(path_data->lock);
// Clear the cache now. Some of its entries could have depended
// on the value we are overriding, and are now out of sync with reality.
@@ -243,7 +243,7 @@ void PathService::RegisterProvider(ProviderFunc func, int key_start,
DCHECK(path_data);
DCHECK(key_end > key_start);
- AutoLock scoped_lock(path_data->lock);
+ base::AutoLock scoped_lock(path_data->lock);
Provider* p;
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_;
diff --git a/base/third_party/dmg_fp/dtoa_wrapper.cc b/base/third_party/dmg_fp/dtoa_wrapper.cc
index fbbaf80..e34b8a6 100644
--- a/base/third_party/dmg_fp/dtoa_wrapper.cc
+++ b/base/third_party/dmg_fp/dtoa_wrapper.cc
@@ -4,12 +4,12 @@
//
// The purpose of this file is to supply the macro definintions necessary
// to make third_party/dmg_fp/dtoa.cc threadsafe.
-#include "base/lock.h"
+#include "base/synchronization/lock.h"
#include "base/logging.h"
// We need two locks because they're sometimes grabbed at the same time.
// A single lock would lead to an attempted recursive grab.
-static Lock dtoa_locks[2];
+static base::Lock dtoa_locks[2];
/*
* This define and the code below is to trigger thread-safe behavior
diff --git a/base/threading/simple_thread.h b/base/threading/simple_thread.h
index f55bd62..1631336 100644
--- a/base/threading/simple_thread.h
+++ b/base/threading/simple_thread.h
@@ -46,8 +46,8 @@
#include <vector>
#include "base/basictypes.h"
-#include "base/lock.h"
#include "base/threading/platform_thread.h"
+#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
namespace base {
@@ -173,7 +173,7 @@ class DelegateSimpleThreadPool : public DelegateSimpleThread::Delegate {
int num_threads_;
std::vector<DelegateSimpleThread*> threads_;
std::queue<Delegate*> delegates_;
- Lock lock_; // Locks delegates_
+ base::Lock lock_; // Locks delegates_
WaitableEvent dry_; // Not signaled when there is no work to do.
};
diff --git a/base/threading/thread_checker.h b/base/threading/thread_checker.h
index c0010fb..712b5b5 100644
--- a/base/threading/thread_checker.h
+++ b/base/threading/thread_checker.h
@@ -7,7 +7,7 @@
#pragma once
#ifndef NDEBUG
-#include "base/lock.h"
+#include "base/synchronization/lock.h"
#include "base/threading/platform_thread.h"
#endif // NDEBUG
@@ -51,7 +51,7 @@ class ThreadChecker {
private:
void EnsureThreadIdAssigned() const;
- mutable Lock lock_;
+ mutable base::Lock lock_;
// This is mutable so that CalledOnValidThread can set it.
// It's guarded by |lock_|.
mutable PlatformThreadId valid_thread_id_;
diff --git a/base/threading/thread_collision_warner_unittest.cc b/base/threading/thread_collision_warner_unittest.cc
index 68987c3..a3d3b66 100644
--- a/base/threading/thread_collision_warner_unittest.cc
+++ b/base/threading/thread_collision_warner_unittest.cc
@@ -3,8 +3,8 @@
// found in the LICENSE file.
#include "base/compiler_specific.h"
-#include "base/lock.h"
#include "base/scoped_ptr.h"
+#include "base/synchronization/lock.h"
#include "base/threading/platform_thread.h"
#include "base/threading/simple_thread.h"
#include "base/threading/thread_collision_warner.h"
@@ -266,30 +266,30 @@ TEST(ThreadCollisionTest, MTSynchedScopedBookCriticalSectionTest) {
// a lock.
class QueueUser : public base::DelegateSimpleThread::Delegate {
public:
- QueueUser(NonThreadSafeQueue& queue, Lock& lock)
+ QueueUser(NonThreadSafeQueue& queue, base::Lock& lock)
: queue_(queue),
lock_(lock) {}
virtual void Run() {
{
- AutoLock auto_lock(lock_);
+ base::AutoLock auto_lock(lock_);
queue_.push(0);
}
{
- AutoLock auto_lock(lock_);
+ base::AutoLock auto_lock(lock_);
queue_.pop();
}
}
private:
NonThreadSafeQueue& queue_;
- Lock& lock_;
+ base::Lock& lock_;
};
AssertReporter* local_reporter = new AssertReporter();
NonThreadSafeQueue queue(local_reporter);
- Lock lock;
+ base::Lock lock;
QueueUser queue_user_a(queue, lock);
QueueUser queue_user_b(queue, lock);
@@ -340,34 +340,34 @@ TEST(ThreadCollisionTest, MTSynchedScopedRecursiveBookCriticalSectionTest) {
// a lock.
class QueueUser : public base::DelegateSimpleThread::Delegate {
public:
- QueueUser(NonThreadSafeQueue& queue, Lock& lock)
+ QueueUser(NonThreadSafeQueue& queue, base::Lock& lock)
: queue_(queue),
lock_(lock) {}
virtual void Run() {
{
- AutoLock auto_lock(lock_);
+ base::AutoLock auto_lock(lock_);
queue_.push(0);
}
{
- AutoLock auto_lock(lock_);
+ base::AutoLock auto_lock(lock_);
queue_.bar();
}
{
- AutoLock auto_lock(lock_);
+ base::AutoLock auto_lock(lock_);
queue_.pop();
}
}
private:
NonThreadSafeQueue& queue_;
- Lock& lock_;
+ base::Lock& lock_;
};
AssertReporter* local_reporter = new AssertReporter();
NonThreadSafeQueue queue(local_reporter);
- Lock lock;
+ base::Lock lock;
QueueUser queue_user_a(queue, lock);
QueueUser queue_user_b(queue, lock);
diff --git a/base/threading/worker_pool_posix_unittest.cc b/base/threading/worker_pool_posix_unittest.cc
index 332c55e..c984ee3 100644
--- a/base/threading/worker_pool_posix_unittest.cc
+++ b/base/threading/worker_pool_posix_unittest.cc
@@ -6,8 +6,8 @@
#include <set>
-#include "base/lock.h"
#include "base/synchronization/condition_variable.h"
+#include "base/synchronization/lock.h"
#include "base/task.h"
#include "base/threading/platform_thread.h"
#include "base/synchronization/waitable_event.h"
@@ -61,12 +61,12 @@ class IncrementingTask : public Task {
virtual void Run() {
AddSelfToUniqueThreadSet();
- AutoLock locked(*counter_lock_);
+ base::AutoLock locked(*counter_lock_);
(*counter_)++;
}
void AddSelfToUniqueThreadSet() {
- AutoLock locked(*unique_threads_lock_);
+ base::AutoLock locked(*unique_threads_lock_);
unique_threads_->insert(PlatformThread::CurrentId());
}
@@ -100,7 +100,7 @@ class BlockingIncrementingTask : public Task {
virtual void Run() {
{
- AutoLock num_waiting_to_start_locked(*num_waiting_to_start_lock_);
+ base::AutoLock num_waiting_to_start_locked(*num_waiting_to_start_lock_);
(*num_waiting_to_start_)++;
}
num_waiting_to_start_cv_->Signal();
@@ -138,14 +138,14 @@ class PosixDynamicThreadPoolTest : public testing::Test {
}
void WaitForTasksToStart(int num_tasks) {
- AutoLock num_waiting_to_start_locked(num_waiting_to_start_lock_);
+ base::AutoLock num_waiting_to_start_locked(num_waiting_to_start_lock_);
while (num_waiting_to_start_ < num_tasks) {
num_waiting_to_start_cv_.Wait();
}
}
void WaitForIdleThreads(int num_idle_threads) {
- AutoLock pool_locked(*peer_.lock());
+ base::AutoLock pool_locked(*peer_.lock());
while (peer_.num_idle_threads() < num_idle_threads) {
peer_.num_idle_threads_cv()->Wait();
}
@@ -249,7 +249,7 @@ TEST_F(PosixDynamicThreadPoolTest, Complex) {
// Wake up all idle threads so they can exit.
{
- AutoLock locked(*peer_.lock());
+ base::AutoLock locked(*peer_.lock());
while (peer_.num_idle_threads() > 0) {
peer_.tasks_available_cv()->Signal();
peer_.num_idle_threads_cv()->Wait();
diff --git a/base/time_win.cc b/base/time_win.cc
index ca3aef1..601211c 100644
--- a/base/time_win.cc
+++ b/base/time_win.cc
@@ -41,10 +41,10 @@
#include <mmsystem.h>
#include "base/basictypes.h"
-#include "base/lock.h"
#include "base/logging.h"
#include "base/cpu.h"
#include "base/singleton.h"
+#include "base/synchronization/lock.h"
using base::Time;
using base::TimeDelta;
@@ -262,7 +262,7 @@ DWORD last_seen_now = 0;
// easy to use a Singleton without even knowing it, and that may lead to many
// gotchas). Its impact on startup time should be negligible due to low-level
// nature of time code.
-Lock rollover_lock;
+base::Lock rollover_lock;
// We use timeGetTime() to implement TimeTicks::Now(). This can be problematic
// because it returns the number of milliseconds since Windows has started,
@@ -270,7 +270,7 @@ Lock rollover_lock;
// rollover ourselves, which works if TimeTicks::Now() is called at least every
// 49 days.
TimeDelta RolloverProtectedNow() {
- AutoLock locked(rollover_lock);
+ base::AutoLock locked(rollover_lock);
// We should hold the lock while calling tick_function to make sure that
// we keep last_seen_now stay correctly in sync.
DWORD now = tick_function();
@@ -409,4 +409,4 @@ int64 TimeTicks::GetQPCDriftMicroseconds() {
// static
bool TimeTicks::IsHighResClockWorking() {
return HighResNowSingleton::GetInstance()->IsUsingHighResClock();
-} \ No newline at end of file
+}
diff --git a/base/tracked_objects.cc b/base/tracked_objects.cc
index d62aa59..a9f81b1 100644
--- a/base/tracked_objects.cc
+++ b/base/tracked_objects.cc
@@ -85,7 +85,7 @@ Births::Births(const Location& location)
// static
ThreadData* ThreadData::first_ = NULL;
// static
-Lock ThreadData::list_lock_;
+base::Lock ThreadData::list_lock_;
// static
ThreadData::Status ThreadData::status_ = ThreadData::UNINITIALIZED;
@@ -111,7 +111,7 @@ ThreadData* ThreadData::current() {
bool too_late_to_create = false;
{
registry = new ThreadData;
- AutoLock lock(list_lock_);
+ base::AutoLock lock(list_lock_);
// Use lock to insure we have most recent status.
if (!IsActive()) {
too_late_to_create = true;
@@ -285,7 +285,7 @@ Births* ThreadData::TallyABirth(const Location& location) {
Births* tracker = new Births(location);
// Lock since the map may get relocated now, and other threads sometimes
// snapshot it (but they lock before copying it).
- AutoLock lock(lock_);
+ base::AutoLock lock(lock_);
birth_map_[location] = tracker;
return tracker;
}
@@ -305,13 +305,13 @@ void ThreadData::TallyADeath(const Births& lifetimes,
return;
}
- AutoLock lock(lock_); // Lock since the map may get relocated now.
+ base::AutoLock lock(lock_); // Lock since the map may get relocated now.
death_map_[&lifetimes].RecordDeath(duration);
}
// static
ThreadData* ThreadData::first() {
- AutoLock lock(list_lock_);
+ base::AutoLock lock(list_lock_);
return first_;
}
@@ -323,7 +323,7 @@ const std::string ThreadData::ThreadName() const {
// This may be called from another thread.
void ThreadData::SnapshotBirthMap(BirthMap *output) const {
- AutoLock lock(lock_);
+ base::AutoLock lock(lock_);
for (BirthMap::const_iterator it = birth_map_.begin();
it != birth_map_.end(); ++it)
(*output)[it->first] = it->second;
@@ -331,7 +331,7 @@ void ThreadData::SnapshotBirthMap(BirthMap *output) const {
// This may be called from another thread.
void ThreadData::SnapshotDeathMap(DeathMap *output) const {
- AutoLock lock(lock_);
+ base::AutoLock lock(lock_);
for (DeathMap::const_iterator it = death_map_.begin();
it != death_map_.end(); ++it)
(*output)[it->first] = it->second;
@@ -348,7 +348,7 @@ void ThreadData::ResetAllThreadData() {
}
void ThreadData::Reset() {
- AutoLock lock(lock_);
+ base::AutoLock lock(lock_);
for (DeathMap::iterator it = death_map_.begin();
it != death_map_.end(); ++it)
it->second.Clear();
@@ -372,7 +372,7 @@ class ThreadData::ThreadSafeDownCounter {
private:
size_t remaining_count_;
- Lock lock_; // protect access to remaining_count_.
+ base::Lock lock_; // protect access to remaining_count_.
};
ThreadData::ThreadSafeDownCounter::ThreadSafeDownCounter(size_t count)
@@ -382,7 +382,7 @@ ThreadData::ThreadSafeDownCounter::ThreadSafeDownCounter(size_t count)
bool ThreadData::ThreadSafeDownCounter::LastCaller() {
{
- AutoLock lock(lock_);
+ base::AutoLock lock(lock_);
if (--remaining_count_)
return false;
} // Release lock, so we can delete everything in this instance.
@@ -461,12 +461,12 @@ bool ThreadData::StartTracking(bool status) {
#endif
if (!status) {
- AutoLock lock(list_lock_);
+ base::AutoLock lock(list_lock_);
DCHECK(status_ == ACTIVE || status_ == SHUTDOWN);
status_ = SHUTDOWN;
return true;
}
- AutoLock lock(list_lock_);
+ base::AutoLock lock(list_lock_);
DCHECK(status_ == UNINITIALIZED);
CHECK(tls_index_.Initialize(NULL));
status_ = ACTIVE;
@@ -504,7 +504,7 @@ void ThreadData::ShutdownSingleThreadedCleanup() {
return;
ThreadData* thread_data_list;
{
- AutoLock lock(list_lock_);
+ base::AutoLock lock(list_lock_);
thread_data_list = first_;
first_ = NULL;
}
@@ -614,7 +614,7 @@ void DataCollector::Append(const ThreadData& thread_data) {
thread_data.SnapshotDeathMap(&death_map);
// Use our lock to protect our accumulation activity.
- AutoLock lock(accumulation_lock_);
+ base::AutoLock lock(accumulation_lock_);
DCHECK(count_of_contributing_threads_);
diff --git a/base/tracked_objects.h b/base/tracked_objects.h
index 07731ff..ed629c3 100644
--- a/base/tracked_objects.h
+++ b/base/tracked_objects.h
@@ -10,7 +10,7 @@
#include <string>
#include <vector>
-#include "base/lock.h"
+#include "base/synchronization/lock.h"
#include "base/tracked.h"
#include "base/threading/thread_local_storage.h"
@@ -322,7 +322,7 @@ class DataCollector {
// seen a death count.
BirthCount global_birth_count_;
- Lock accumulation_lock_; // Protects access during accumulation phase.
+ base::Lock accumulation_lock_; // Protects access during accumulation phase.
DISALLOW_COPY_AND_ASSIGN(DataCollector);
};
@@ -577,7 +577,7 @@ class ThreadData {
// Link to the most recently created instance (starts a null terminated list).
static ThreadData* first_;
// Protection for access to first_.
- static Lock list_lock_;
+ static base::Lock list_lock_;
// We set status_ to SHUTDOWN when we shut down the tracking service. This
// setting is redundantly established by all participating threads so that we
@@ -613,7 +613,7 @@ class ThreadData {
// thread, or reading from another thread. For reading from this thread we
// don't need a lock, as there is no potential for a conflict since the
// writing is only done from this thread.
- mutable Lock lock_;
+ mutable base::Lock lock_;
DISALLOW_COPY_AND_ASSIGN(ThreadData);
};