Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: base/message_loop_proxy.h

Issue 6812016: Clarify documentation about when a task may fail to post to a message loop (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_MESSAGE_LOOP_PROXY_H_ 5 #ifndef BASE_MESSAGE_LOOP_PROXY_H_
6 #define BASE_MESSAGE_LOOP_PROXY_H_ 6 #define BASE_MESSAGE_LOOP_PROXY_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/base_api.h" 9 #include "base/base_api.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/task.h" 12 #include "base/task.h"
13 13
14 namespace base { 14 namespace base {
15 15
16 struct MessageLoopProxyTraits; 16 struct MessageLoopProxyTraits;
17 17
18 // This class provides a thread-safe refcounted interface to the Post* methods 18 // This class provides a thread-safe refcounted interface to the Post* methods
19 // of a message loop. This class can outlive the target message loop. You can 19 // of a message loop. This class can outlive the target message loop. You can
20 // obtain a MessageLoopProxy via Thread::message_loop_proxy() or 20 // obtain a MessageLoopProxy via Thread::message_loop_proxy() or
21 // MessageLoopProxy::CreateForCurrentThread(). 21 // MessageLoopProxy::CreateForCurrentThread().
22 class BASE_API MessageLoopProxy 22 class BASE_API MessageLoopProxy
23 : public base::RefCountedThreadSafe<MessageLoopProxy, 23 : public base::RefCountedThreadSafe<MessageLoopProxy,
24 MessageLoopProxyTraits> { 24 MessageLoopProxyTraits> {
25 public: 25 public:
26 // These methods are the same as in message_loop.h, but are guaranteed to 26 // These methods are the same as in message_loop.h, but are guaranteed to
27 // either post the Task to the MessageLoop (if it's still alive), or to 27 // either post the Task to the MessageLoop (if it's still alive), or to
28 // delete the Task otherwise. 28 // delete the Task otherwise.
29 // They return true iff the thread existed and the task was posted. Note that 29 // They return true iff the thread existed and the task was posted. Note that
30 // even if the task is posted, there's no guarantee that it will run, since 30 // even if the task is posted, there's no guarantee that it will run; for
31 // the target thread may already have a Quit message in its queue. 31 // example the target loop may already be quitting, or in the case of a
32 // delayed task a Quit message may preempt it in the message loop queue.
33 // Conversely, a return value of false is a guarantee the task will not run.
32 virtual bool PostTask(const tracked_objects::Location& from_here, 34 virtual bool PostTask(const tracked_objects::Location& from_here,
33 Task* task) = 0; 35 Task* task) = 0;
34 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, 36 virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
35 Task* task, int64 delay_ms) = 0; 37 Task* task, int64 delay_ms) = 0;
36 virtual bool PostNonNestableTask(const tracked_objects::Location& from_here, 38 virtual bool PostNonNestableTask(const tracked_objects::Location& from_here,
37 Task* task) = 0; 39 Task* task) = 0;
38 virtual bool PostNonNestableDelayedTask( 40 virtual bool PostNonNestableDelayedTask(
39 const tracked_objects::Location& from_here, 41 const tracked_objects::Location& from_here,
40 Task* task, 42 Task* task,
41 int64 delay_ms) = 0; 43 int64 delay_ms) = 0;
(...skipping 30 matching lines...) Expand all
72 74
73 struct MessageLoopProxyTraits { 75 struct MessageLoopProxyTraits {
74 static void Destruct(const MessageLoopProxy* proxy) { 76 static void Destruct(const MessageLoopProxy* proxy) {
75 proxy->OnDestruct(); 77 proxy->OnDestruct();
76 } 78 }
77 }; 79 };
78 80
79 } // namespace base 81 } // namespace base
80 82
81 #endif // BASE_MESSAGE_LOOP_PROXY_H_ 83 #endif // BASE_MESSAGE_LOOP_PROXY_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698