summaryrefslogtreecommitdiffstats
path: root/base/message_loop
diff options
context:
space:
mode:
authorvkuzkokov@chromium.org <vkuzkokov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-30 18:07:17 +0000
committervkuzkokov@chromium.org <vkuzkokov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-30 18:07:17 +0000
commitb76b02780f98983a6da062d68fc28c7ed37f2611 (patch)
treefa984b0aad0595df034b7d27bd98709f695e60f9 /base/message_loop
parent1b63d607782a3278a0e6a529b01d6f56443a942c (diff)
downloadchromium_src-b76b02780f98983a6da062d68fc28c7ed37f2611.zip
chromium_src-b76b02780f98983a6da062d68fc28c7ed37f2611.tar.gz
chromium_src-b76b02780f98983a6da062d68fc28c7ed37f2611.tar.bz2
Fixed example in MessageLoop::ReleaseSoon comment
The previous version could cause race condition if for whatever reason ReleaseSoon finished releasing on another thread before we got to "foo = NULL" BUG= Review URL: https://codereview.chromium.org/301943003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273879 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_loop')
-rw-r--r--base/message_loop/message_loop.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/base/message_loop/message_loop.h b/base/message_loop/message_loop.h
index 25891c5..165299d 100644
--- a/base/message_loop/message_loop.h
+++ b/base/message_loop/message_loop.h
@@ -208,15 +208,16 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate {
// released on a particular thread.
//
// A common pattern is to manually increment the object's reference count
- // (AddRef), issue a ReleaseSoon, then clear the pointer. The reference count
+ // (AddRef), clear the pointer, then issue a ReleaseSoon. The reference count
// is incremented manually to ensure clearing the pointer does not trigger a
// delete and to account for the upcoming decrement (ReleaseSoon). For
// example:
//
// scoped_refptr<Foo> foo = ...
- // foo.AddRef();
- // message_loop->ReleaseSoon(foo.get());
+ // foo->AddRef();
+ // Foo* raw_foo = foo.get();
// foo = NULL;
+ // message_loop->ReleaseSoon(raw_foo);
//
// NOTE: This method may be called on any thread. The object will be
// released (and thus possibly deleted) on the thread that executes