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

Side by Side Diff: base/message_loop/message_loop_task_runner.cc

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/message_loop/message_loop_task_runner.h ('k') | base/sequenced_task_runner.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "base/message_loop/message_loop_task_runner.h" 5 #include "base/message_loop/message_loop_task_runner.h"
6 6
7 #include <utility>
8
7 #include "base/location.h" 9 #include "base/location.h"
8 #include "base/logging.h" 10 #include "base/logging.h"
9 #include "base/message_loop/incoming_task_queue.h" 11 #include "base/message_loop/incoming_task_queue.h"
10 12
11 namespace base { 13 namespace base {
12 namespace internal { 14 namespace internal {
13 15
14 MessageLoopTaskRunner::MessageLoopTaskRunner( 16 MessageLoopTaskRunner::MessageLoopTaskRunner(
15 scoped_refptr<IncomingTaskQueue> incoming_queue) 17 scoped_refptr<IncomingTaskQueue> incoming_queue)
16 : incoming_queue_(incoming_queue), valid_thread_id_(kInvalidThreadId) { 18 : incoming_queue_(incoming_queue), valid_thread_id_(kInvalidThreadId) {
17 } 19 }
18 20
19 void MessageLoopTaskRunner::BindToCurrentThread() { 21 void MessageLoopTaskRunner::BindToCurrentThread() {
20 AutoLock lock(valid_thread_id_lock_); 22 AutoLock lock(valid_thread_id_lock_);
21 DCHECK_EQ(kInvalidThreadId, valid_thread_id_); 23 DCHECK_EQ(kInvalidThreadId, valid_thread_id_);
22 valid_thread_id_ = PlatformThread::CurrentId(); 24 valid_thread_id_ = PlatformThread::CurrentId();
23 } 25 }
24 26
25 bool MessageLoopTaskRunner::PostDelayedTask( 27 bool MessageLoopTaskRunner::PostDelayedTask(
26 const tracked_objects::Location& from_here, 28 const tracked_objects::Location& from_here,
27 const base::Closure& task, 29 Closure task,
28 base::TimeDelta delay) { 30 base::TimeDelta delay) {
29 DCHECK(!task.is_null()) << from_here.ToString(); 31 DCHECK(!task.is_null()) << from_here.ToString();
30 return incoming_queue_->AddToIncomingQueue(from_here, task, delay, true); 32 return incoming_queue_->AddToIncomingQueue(from_here, std::move(task), delay,
33 true);
31 } 34 }
32 35
33 bool MessageLoopTaskRunner::PostNonNestableDelayedTask( 36 bool MessageLoopTaskRunner::PostNonNestableDelayedTask(
34 const tracked_objects::Location& from_here, 37 const tracked_objects::Location& from_here,
35 const base::Closure& task, 38 Closure task,
36 base::TimeDelta delay) { 39 base::TimeDelta delay) {
37 DCHECK(!task.is_null()) << from_here.ToString(); 40 DCHECK(!task.is_null()) << from_here.ToString();
38 return incoming_queue_->AddToIncomingQueue(from_here, task, delay, false); 41 return incoming_queue_->AddToIncomingQueue(from_here, std::move(task), delay,
42 false);
39 } 43 }
40 44
41 bool MessageLoopTaskRunner::RunsTasksOnCurrentThread() const { 45 bool MessageLoopTaskRunner::RunsTasksOnCurrentThread() const {
42 AutoLock lock(valid_thread_id_lock_); 46 AutoLock lock(valid_thread_id_lock_);
43 return valid_thread_id_ == PlatformThread::CurrentId(); 47 return valid_thread_id_ == PlatformThread::CurrentId();
44 } 48 }
45 49
46 MessageLoopTaskRunner::~MessageLoopTaskRunner() { 50 MessageLoopTaskRunner::~MessageLoopTaskRunner() {
47 } 51 }
48 52
49 } // namespace internal 53 } // namespace internal
50 54
51 } // namespace base 55 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/message_loop_task_runner.h ('k') | base/sequenced_task_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698