diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-30 08:54:17 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-30 08:54:17 +0000 |
commit | 2a59a9065e6cbb949162964f75e962ad3a2349d7 (patch) | |
tree | 1f80085ab95d5dd8bc694897218e06a1a3216fdc /base/synchronization | |
parent | 60d6cca71d7aeed69b5f11abe1273063b94d6d13 (diff) | |
download | chromium_src-2a59a9065e6cbb949162964f75e962ad3a2349d7.zip chromium_src-2a59a9065e6cbb949162964f75e962ad3a2349d7.tar.gz chromium_src-2a59a9065e6cbb949162964f75e962ad3a2349d7.tar.bz2 |
Adding TryPostTask to the message loop
This is to allow code in certain high priority threads
to use the task/message loop facility. For example the
audio threads that currently use sentinel booleans and
recurring timers.
TryPostTask will fail if it is going contend for
the lock. The caller must handle that case.
Note that the current tests do not test the contended
mode. I don't see a way to test that case without
introducing runtime penalty for all of chrome.
BUG=none
TEST=included
Review URL: https://chromiumcodereview.appspot.com/14387002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@197315 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/synchronization')
-rw-r--r-- | base/synchronization/lock.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/base/synchronization/lock.h b/base/synchronization/lock.h index bec37fb..7e8ffe7 100644 --- a/base/synchronization/lock.h +++ b/base/synchronization/lock.h @@ -96,10 +96,16 @@ class BASE_EXPORT Lock { // A helper class that acquires the given Lock while the AutoLock is in scope. class AutoLock { public: + struct AlreadyAcquired {}; + explicit AutoLock(Lock& lock) : lock_(lock) { lock_.Acquire(); } + AutoLock(Lock& lock, const AlreadyAcquired&) : lock_(lock) { + lock_.AssertAcquired(); + } + ~AutoLock() { lock_.AssertAcquired(); lock_.Release(); |