diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-29 21:18:15 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-29 21:18:15 +0000 |
commit | 30ca5b27dd289835211002a26fdb484de51bf476 (patch) | |
tree | 506cc517e9d0f1307973528ea01530b14749845b /content/browser/browser_thread_impl.cc | |
parent | 2cf451f7cdfb6b2ae4f2b6a7270ae3b942cb8412 (diff) | |
download | chromium_src-30ca5b27dd289835211002a26fdb484de51bf476.zip chromium_src-30ca5b27dd289835211002a26fdb484de51bf476.tar.gz chromium_src-30ca5b27dd289835211002a26fdb484de51bf476.tar.bz2 |
Fix regression in BrowserThread's optimization of when it skips a lock. The variable name was misnamed before, which contributed to this. I've updated the variable name to make it clearer.
Credit to liujundota@gmail.com who noticed this.
Review URL: https://chromiumcodereview.appspot.com/10900020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153977 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/browser_thread_impl.cc')
-rw-r--r-- | content/browser/browser_thread_impl.cc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/content/browser/browser_thread_impl.cc b/content/browser/browser_thread_impl.cc index c0bd988..fff9625 100644 --- a/content/browser/browser_thread_impl.cc +++ b/content/browser/browser_thread_impl.cc @@ -232,18 +232,18 @@ bool BrowserThreadImpl::PostTaskHelper( bool nestable) { DCHECK(identifier >= 0 && identifier < ID_COUNT); // Optimization: to avoid unnecessary locks, we listed the ID enumeration in - // order of lifetime. So no need to lock if we know that the other thread - // outlives this one. + // order of lifetime. So no need to lock if we know that the target thread + // outlives current thread. // Note: since the array is so small, ok to loop instead of creating a map, // which would require a lock because std::map isn't thread safe, defeating // the whole purpose of this optimization. BrowserThread::ID current_thread; - bool guaranteed_to_outlive_target_thread = + bool target_thread_outlives_current = GetCurrentThreadIdentifier(¤t_thread) && - current_thread <= identifier; + current_thread >= identifier; BrowserThreadGlobals& globals = g_globals.Get(); - if (!guaranteed_to_outlive_target_thread) + if (!target_thread_outlives_current) globals.lock.Acquire(); MessageLoop* message_loop = globals.threads[identifier] ? @@ -256,7 +256,7 @@ bool BrowserThreadImpl::PostTaskHelper( } } - if (!guaranteed_to_outlive_target_thread) + if (!target_thread_outlives_current) globals.lock.Release(); return !!message_loop; |