summaryrefslogtreecommitdiffstats
path: root/base/message_loop/message_loop.h
diff options
context:
space:
mode:
authormaniscalco@chromium.org <maniscalco@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-27 22:37:50 +0000
committermaniscalco@chromium.org <maniscalco@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-27 22:37:50 +0000
commitab8748ec61f0a2690e91f3f86f3d5e2ec43f1eb3 (patch)
tree54555d4bccd0805641d60b001ea97f500ddfdc46 /base/message_loop/message_loop.h
parent63fd1399de0659ae2bc91dc92d95cf792060e5fa (diff)
downloadchromium_src-ab8748ec61f0a2690e91f3f86f3d5e2ec43f1eb3.zip
chromium_src-ab8748ec61f0a2690e91f3f86f3d5e2ec43f1eb3.tar.gz
chromium_src-ab8748ec61f0a2690e91f3f86f3d5e2ec43f1eb3.tar.bz2
Add example to MessageLoop::ReleaseSoon comment.
BUG= Review URL: https://codereview.chromium.org/302633009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273059 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_loop/message_loop.h')
-rw-r--r--base/message_loop/message_loop.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/base/message_loop/message_loop.h b/base/message_loop/message_loop.h
index 4bb7d55..25891c5 100644
--- a/base/message_loop/message_loop.h
+++ b/base/message_loop/message_loop.h
@@ -207,6 +207,17 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate {
// live until the next run of the MessageLoop, or if the object needs to be
// 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
+ // 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 = NULL;
+ //
// NOTE: This method may be called on any thread. The object will be
// released (and thus possibly deleted) on the thread that executes
// MessageLoop::Run(). If this is not the same as the thread that calls