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

Side by Side Diff: base/threading/sequenced_task_runner_handle.cc

Issue 1423773003: Add SequencedTaskRunnerHandle to get a SequencedTaskRunner for the current thread / sequence. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 5 years, 2 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/threading/sequenced_task_runner_handle.h ('k') | base/threading/sequenced_worker_pool.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/threading/sequenced_task_runner_handle.h"
6
7 #include "base/sequenced_task_runner.h"
8 #include "base/thread_task_runner_handle.h"
9 #include "base/threading/sequenced_worker_pool.h"
10
11 namespace base {
12
13 // static
14 scoped_refptr<SequencedTaskRunner> SequencedTaskRunnerHandle::Get() {
15 // If we are on a worker thread for a SequencedBlockingPool that is running a
16 // sequenced task, return a SequencedTaskRunner for it.
17 scoped_refptr<base::SequencedWorkerPool> pool =
18 SequencedWorkerPool::GetWorkerPoolForCurrentThread();
19 if (pool) {
20 SequencedWorkerPool::SequenceToken sequence_token =
21 SequencedWorkerPool::GetSequenceTokenForCurrentThread();
22 DCHECK(sequence_token.IsValid());
23 DCHECK(pool->IsRunningSequenceOnCurrentThread(sequence_token));
24 return pool->GetSequencedTaskRunner(sequence_token);
25 }
26
27 // Otherwise, return a SingleThreadTaskRunner for the current thread.
28 return base::ThreadTaskRunnerHandle::Get();
29 }
30
31 // static
32 bool SequencedTaskRunnerHandle::IsSet() {
33 return (SequencedWorkerPool::GetWorkerPoolForCurrentThread() &&
34 SequencedWorkerPool::GetSequenceTokenForCurrentThread().IsValid()) ||
35 base::ThreadTaskRunnerHandle::IsSet();
gab 2015/10/23 16:19:21 nit: missing a space.
Bernhard Bauer 2015/10/23 16:24:00 Clang-format did that (I think it's aligning the r
gab 2015/10/23 16:39:10 As sorry missed the extra bracket -- clang > gab :
36 }
37
38 } // namespace base
OLDNEW
« no previous file with comments | « base/threading/sequenced_task_runner_handle.h ('k') | base/threading/sequenced_worker_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698