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

Side by Side Diff: base/message_loop/incoming_task_queue.h

Issue 2726523002: Pass Callback to TaskRunner by value and consume it on invocation (1) (Closed)
Patch Set: erase Closure* Created 3 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
« no previous file with comments | « base/deferred_sequenced_task_runner.cc ('k') | base/message_loop/incoming_task_queue.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_INCOMING_TASK_QUEUE_H_ 5 #ifndef BASE_MESSAGE_LOOP_INCOMING_TASK_QUEUE_H_
6 #define BASE_MESSAGE_LOOP_INCOMING_TASK_QUEUE_H_ 6 #define BASE_MESSAGE_LOOP_INCOMING_TASK_QUEUE_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/callback.h"
9 #include "base/macros.h" 10 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
11 #include "base/pending_task.h" 12 #include "base/pending_task.h"
12 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
13 #include "base/synchronization/read_write_lock.h" 14 #include "base/synchronization/read_write_lock.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 16
16 namespace base { 17 namespace base {
17 18
18 class MessageLoop; 19 class MessageLoop;
19 20
20 namespace internal { 21 namespace internal {
21 22
22 // Implements a queue of tasks posted to the message loop running on the current 23 // Implements a queue of tasks posted to the message loop running on the current
23 // thread. This class takes care of synchronizing posting tasks from different 24 // thread. This class takes care of synchronizing posting tasks from different
24 // threads and together with MessageLoop ensures clean shutdown. 25 // threads and together with MessageLoop ensures clean shutdown.
25 class BASE_EXPORT IncomingTaskQueue 26 class BASE_EXPORT IncomingTaskQueue
26 : public RefCountedThreadSafe<IncomingTaskQueue> { 27 : public RefCountedThreadSafe<IncomingTaskQueue> {
27 public: 28 public:
28 explicit IncomingTaskQueue(MessageLoop* message_loop); 29 explicit IncomingTaskQueue(MessageLoop* message_loop);
29 30
30 // Appends a task to the incoming queue. Posting of all tasks is routed though 31 // Appends a task to the incoming queue. Posting of all tasks is routed though
31 // AddToIncomingQueue() or TryAddToIncomingQueue() to make sure that posting 32 // AddToIncomingQueue() or TryAddToIncomingQueue() to make sure that posting
32 // task is properly synchronized between different threads. 33 // task is properly synchronized between different threads.
33 // 34 //
34 // Returns true if the task was successfully added to the queue, otherwise 35 // Returns true if the task was successfully added to the queue, otherwise
35 // returns false. In all cases, the ownership of |task| is transferred to the 36 // returns false. In all cases, the ownership of |task| is transferred to the
36 // called method. 37 // called method.
37 bool AddToIncomingQueue(const tracked_objects::Location& from_here, 38 bool AddToIncomingQueue(const tracked_objects::Location& from_here,
38 const Closure& task, 39 Closure task,
39 TimeDelta delay, 40 TimeDelta delay,
40 bool nestable); 41 bool nestable);
41 42
42 // Returns true if the queue contains tasks that require higher than default 43 // Returns true if the queue contains tasks that require higher than default
43 // timer resolution. Currently only needed for Windows. 44 // timer resolution. Currently only needed for Windows.
44 bool HasHighResolutionTasks(); 45 bool HasHighResolutionTasks();
45 46
46 // Returns true if the message loop is "idle". Provided for testing. 47 // Returns true if the message loop is "idle". Provided for testing.
47 bool IsIdleForTesting(); 48 bool IsIdleForTesting();
48 49
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // False until StartScheduling() is called. 106 // False until StartScheduling() is called.
106 bool is_ready_for_scheduling_; 107 bool is_ready_for_scheduling_;
107 108
108 DISALLOW_COPY_AND_ASSIGN(IncomingTaskQueue); 109 DISALLOW_COPY_AND_ASSIGN(IncomingTaskQueue);
109 }; 110 };
110 111
111 } // namespace internal 112 } // namespace internal
112 } // namespace base 113 } // namespace base
113 114
114 #endif // BASE_MESSAGE_LOOP_INCOMING_TASK_QUEUE_H_ 115 #endif // BASE_MESSAGE_LOOP_INCOMING_TASK_QUEUE_H_
OLDNEW
« no previous file with comments | « base/deferred_sequenced_task_runner.cc ('k') | base/message_loop/incoming_task_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698