Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef BASE_THREAD_TASK_RUNNER_HANDLE_H_ | 5 #ifndef BASE_THREAD_TASK_RUNNER_HANDLE_H_ |
| 6 #define BASE_THREAD_TASK_RUNNER_HANDLE_H_ | 6 #define BASE_THREAD_TASK_RUNNER_HANDLE_H_ |
| 7 | 7 |
| 8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 | 10 |
| 11 namespace base { | 11 namespace base { |
| 12 | 12 |
| 13 class SingleThreadTaskRunner; | 13 class SingleThreadTaskRunner; |
| 14 | 14 |
| 15 // ThreadTaskRunnerHandle stores a reference to a thread's TaskRunner | 15 // ThreadTaskRunnerHandle stores a reference to a thread's TaskRunner |
| 16 // in thread-local storage. Callers can then retrieve the TaskRunner | 16 // in thread-local storage. Callers can then retrieve the TaskRunner |
| 17 // for the current thread by calling ThreadTaskRunnerHandle::Get(). | 17 // for the current thread by calling ThreadTaskRunnerHandle::Get(). |
| 18 // At most one TaskRunner may be bound to each thread at a time. | 18 // At most one TaskRunner may be bound to each thread at a time. |
| 19 // Note that the returned SingleThreadTaskRunner guarantees thread affinity, and | |
| 20 // therefore this method can't be called for example on a worker thread for a | |
| 21 // SequencedWorkerPool. If you only require sequencing behavior (i.e. that | |
| 22 // posted tasks run after each other), use SequencedTaskRunnerHandle instead. | |
|
gab
2015/10/27 16:57:58
I suggest changing all of this new text with:
//
Bernhard Bauer
2015/10/27 18:03:40
Done.
| |
| 19 class BASE_EXPORT ThreadTaskRunnerHandle { | 23 class BASE_EXPORT ThreadTaskRunnerHandle { |
| 20 public: | 24 public: |
| 21 // Gets the SingleThreadTaskRunner for the current thread. | 25 // Gets the SingleThreadTaskRunner for the current thread. |
| 22 static scoped_refptr<SingleThreadTaskRunner> Get(); | 26 static scoped_refptr<SingleThreadTaskRunner> Get(); |
| 23 | 27 |
| 24 // Returns true if the SingleThreadTaskRunner is already created for | 28 // Returns true if the SingleThreadTaskRunner is already created for |
| 25 // the current thread. | 29 // the current thread. |
| 26 static bool IsSet(); | 30 static bool IsSet(); |
| 27 | 31 |
| 28 // Binds |task_runner| to the current thread. |task_runner| must belong | 32 // Binds |task_runner| to the current thread. |task_runner| must belong |
| 29 // to the current thread for this to succeed. | 33 // to the current thread for this to succeed. |
| 30 explicit ThreadTaskRunnerHandle( | 34 explicit ThreadTaskRunnerHandle( |
| 31 const scoped_refptr<SingleThreadTaskRunner>& task_runner); | 35 const scoped_refptr<SingleThreadTaskRunner>& task_runner); |
| 32 ~ThreadTaskRunnerHandle(); | 36 ~ThreadTaskRunnerHandle(); |
| 33 | 37 |
| 34 private: | 38 private: |
| 35 scoped_refptr<SingleThreadTaskRunner> task_runner_; | 39 scoped_refptr<SingleThreadTaskRunner> task_runner_; |
| 36 }; | 40 }; |
| 37 | 41 |
| 38 } // namespace base | 42 } // namespace base |
| 39 | 43 |
| 40 #endif // BASE_THREAD_TASK_RUNNER_HANDLE_H_ | 44 #endif // BASE_THREAD_TASK_RUNNER_HANDLE_H_ |
| OLD | NEW |