| 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_SINGLE_THREAD_TASK_RUNNER_H_ | 5 #ifndef BASE_SINGLE_THREAD_TASK_RUNNER_H_ |
| 6 #define BASE_SINGLE_THREAD_TASK_RUNNER_H_ | 6 #define BASE_SINGLE_THREAD_TASK_RUNNER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/base_export.h" | 9 #include "base/base_export.h" |
| 10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // and has a method Run() that runs each runnable task in FIFO | 25 // and has a method Run() that runs each runnable task in FIFO |
| 26 // order that must be run only from the thread the | 26 // order that must be run only from the thread the |
| 27 // SingleThreadTaskRunner was created on. | 27 // SingleThreadTaskRunner was created on. |
| 28 class BASE_EXPORT SingleThreadTaskRunner : public SequencedTaskRunner { | 28 class BASE_EXPORT SingleThreadTaskRunner : public SequencedTaskRunner { |
| 29 public: | 29 public: |
| 30 // A more explicit alias to RunsTasksOnCurrentThread(). | 30 // A more explicit alias to RunsTasksOnCurrentThread(). |
| 31 bool BelongsToCurrentThread() const { | 31 bool BelongsToCurrentThread() const { |
| 32 return RunsTasksOnCurrentThread(); | 32 return RunsTasksOnCurrentThread(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 // Gets the SingleThreadTaskRunner for the current thread. |
| 36 static scoped_refptr<SingleThreadTaskRunner> current(); |
| 37 |
| 38 // Sets SingleThreadTaskRunner for the current thread. The caller |
| 39 // must keep a reference to the task runner and call this method |
| 40 // again with new_current=NULL before dropping that reference. |
| 41 static void SetCurrent(SingleThreadTaskRunner* new_current); |
| 42 |
| 35 protected: | 43 protected: |
| 36 virtual ~SingleThreadTaskRunner() {} | 44 virtual ~SingleThreadTaskRunner() {} |
| 37 }; | 45 }; |
| 38 | 46 |
| 39 } // namespace base | 47 } // namespace base |
| 40 | 48 |
| 41 #endif // BASE_SERIAL_TASK_RUNNER_H_ | 49 #endif // BASE_SERIAL_TASK_RUNNER_H_ |
| OLD | NEW |