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_THREADING_SEQUENCED_WORKER_POOL_H_ | 5 #ifndef BASE_THREADING_SEQUENCED_WORKER_POOL_H_ |
| 6 #define BASE_THREADING_SEQUENCED_WORKER_POOL_H_ | 6 #define BASE_THREADING_SEQUENCED_WORKER_POOL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/base_export.h" | 11 #include "base/base_export.h" |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/task_runner.h" | |
| 15 | 16 |
| 16 namespace tracked_objects { | 17 namespace tracked_objects { |
| 17 class Location; | 18 class Location; |
| 18 } // namespace tracked_objects | 19 } // namespace tracked_objects |
| 19 | 20 |
| 20 namespace base { | 21 namespace base { |
| 21 | 22 |
| 22 namespace internal { | 23 namespace internal { |
| 23 class SequencedWorkerPoolInner; | 24 class SequencedWorkerPoolInner; |
| 24 } // namespace internal | 25 } // namespace internal |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 // Returns a unique token that can be used to sequence tasks posted to | 129 // Returns a unique token that can be used to sequence tasks posted to |
| 129 // PostSequencedWorkerTask(). Valid tokens are alwys nonzero. | 130 // PostSequencedWorkerTask(). Valid tokens are alwys nonzero. |
| 130 SequenceToken GetSequenceToken(); | 131 SequenceToken GetSequenceToken(); |
| 131 | 132 |
| 132 // Returns the sequence token associated with the given name. Calling this | 133 // Returns the sequence token associated with the given name. Calling this |
| 133 // function multiple times with the same string will always produce the | 134 // function multiple times with the same string will always produce the |
| 134 // same sequence token. If the name has not been used before, a new token | 135 // same sequence token. If the name has not been used before, a new token |
| 135 // will be created. | 136 // will be created. |
| 136 SequenceToken GetNamedSequenceToken(const std::string& name); | 137 SequenceToken GetNamedSequenceToken(const std::string& name); |
| 137 | 138 |
| 139 // Returns a TaskRunner which posts (unseqenced) tasks on this | |
|
willchan no longer on Chromium
2012/02/19 06:37:01
unsequenced
akalin
2012/02/22 22:39:11
Rendered moot (since this function doesn't exist a
| |
| 140 // worker pool with BLOCK_SHUTDOWN. | |
| 141 scoped_refptr<TaskRunner> GetTaskRunner(); | |
| 142 | |
| 138 // Posts the given task for execution in the worker pool. Tasks posted with | 143 // Posts the given task for execution in the worker pool. Tasks posted with |
| 139 // this function will execute in an unspecified order on a background thread. | 144 // this function will execute in an unspecified order on a background thread. |
| 140 // Returns true if the task was posted. If your tasks have ordering | 145 // Returns true if the task was posted. If your tasks have ordering |
| 141 // requirements, see PostSequencedWorkerTask(). | 146 // requirements, see PostSequencedWorkerTask(). |
| 142 // | 147 // |
| 143 // This class will attempt to delete tasks that aren't run | 148 // This class will attempt to delete tasks that aren't run |
| 144 // (non-block-shutdown semantics) but can't guarantee that this happens. If | 149 // (non-block-shutdown semantics) but can't guarantee that this happens. If |
| 145 // all worker threads are busy running CONTINUE_ON_SHUTDOWN tasks, there | 150 // all worker threads are busy running CONTINUE_ON_SHUTDOWN tasks, there |
| 146 // will be no workers available to delete these tasks. And there may be | 151 // will be no workers available to delete these tasks. And there may be |
| 147 // tasks with the same sequence token behind those CONTINUE_ON_SHUTDOWN | 152 // tasks with the same sequence token behind those CONTINUE_ON_SHUTDOWN |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 | 219 |
| 215 private: | 220 private: |
| 216 scoped_refptr<internal::SequencedWorkerPoolInner> inner_; | 221 scoped_refptr<internal::SequencedWorkerPoolInner> inner_; |
| 217 | 222 |
| 218 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool); | 223 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool); |
| 219 }; | 224 }; |
| 220 | 225 |
| 221 } // namespace base | 226 } // namespace base |
| 222 | 227 |
| 223 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_ | 228 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_ |
| OLD | NEW |