OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_THREADING_THREAD_TASK_RUNNER_HANDLE_H_ | 5 #ifndef BASE_THREADING_THREAD_TASK_RUNNER_HANDLE_H_ |
6 #define BASE_THREADING_THREAD_TASK_RUNNER_HANDLE_H_ | 6 #define BASE_THREADING_THREAD_TASK_RUNNER_HANDLE_H_ |
7 | 7 |
8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 | 15 |
16 // ThreadTaskRunnerHandle stores a reference to a thread's TaskRunner | 16 // ThreadTaskRunnerHandle stores a reference to a thread's TaskRunner |
17 // in thread-local storage. Callers can then retrieve the TaskRunner | 17 // in thread-local storage. Callers can then retrieve the TaskRunner |
18 // for the current thread by calling ThreadTaskRunnerHandle::Get(). | 18 // for the current thread by calling ThreadTaskRunnerHandle::Get(). |
19 // At most one TaskRunner may be bound to each thread at a time. | 19 // At most one TaskRunner may be bound to each thread at a time. |
20 // Prefer SequenceTaskRunnerHandle to this unless thread affinity is required. | 20 // Prefer SequencedTaskRunnerHandle to this unless thread affinity is required. |
21 class BASE_EXPORT ThreadTaskRunnerHandle { | 21 class BASE_EXPORT ThreadTaskRunnerHandle { |
22 public: | 22 public: |
23 // Gets the SingleThreadTaskRunner for the current thread. | 23 // Gets the SingleThreadTaskRunner for the current thread. |
24 static scoped_refptr<SingleThreadTaskRunner> Get(); | 24 static scoped_refptr<SingleThreadTaskRunner> Get(); |
25 | 25 |
26 // Returns true if the SingleThreadTaskRunner is already created for | 26 // Returns true if the SingleThreadTaskRunner is already created for |
27 // the current thread. | 27 // the current thread. |
28 static bool IsSet(); | 28 static bool IsSet(); |
29 | 29 |
30 // Overrides ThreadTaskRunnerHandle::Get()'s |task_runner_| to point at | 30 // Overrides ThreadTaskRunnerHandle::Get()'s |task_runner_| to point at |
(...skipping 15 matching lines...) Expand all Loading... |
46 | 46 |
47 private: | 47 private: |
48 scoped_refptr<SingleThreadTaskRunner> task_runner_; | 48 scoped_refptr<SingleThreadTaskRunner> task_runner_; |
49 | 49 |
50 DISALLOW_COPY_AND_ASSIGN(ThreadTaskRunnerHandle); | 50 DISALLOW_COPY_AND_ASSIGN(ThreadTaskRunnerHandle); |
51 }; | 51 }; |
52 | 52 |
53 } // namespace base | 53 } // namespace base |
54 | 54 |
55 #endif // BASE_THREADING_THREAD_TASK_RUNNER_HANDLE_H_ | 55 #endif // BASE_THREADING_THREAD_TASK_RUNNER_HANDLE_H_ |
OLD | NEW |