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 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <cstddef> | 10 #include <cstddef> |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 // assumptions of the running task. | 271 // assumptions of the running task. |
272 // | 272 // |
273 // The task will be guaranteed to run to completion before shutdown | 273 // The task will be guaranteed to run to completion before shutdown |
274 // (BLOCK_SHUTDOWN semantics). | 274 // (BLOCK_SHUTDOWN semantics). |
275 // | 275 // |
276 // Returns true if the task was posted successfully. This may fail during | 276 // Returns true if the task was posted successfully. This may fail during |
277 // shutdown regardless of the specified ShutdownBehavior. | 277 // shutdown regardless of the specified ShutdownBehavior. |
278 bool PostWorkerTask(const tracked_objects::Location& from_here, | 278 bool PostWorkerTask(const tracked_objects::Location& from_here, |
279 OnceClosure task); | 279 OnceClosure task); |
280 | 280 |
281 // Same as PostWorkerTask but allows a delay to be specified (although doing | |
282 // so changes the shutdown behavior). The task will be run after the given | |
283 // delay has elapsed. | |
284 // | |
285 // If the delay is nonzero, the task won't be guaranteed to run to completion | |
286 // before shutdown (SKIP_ON_SHUTDOWN semantics) to avoid shutdown hangs. | |
287 // If the delay is zero, this behaves exactly like PostWorkerTask, i.e. the | |
288 // task will be guaranteed to run to completion before shutdown | |
289 // (BLOCK_SHUTDOWN semantics). | |
290 bool PostDelayedWorkerTask(const tracked_objects::Location& from_here, | |
291 OnceClosure task, | |
292 TimeDelta delay); | |
293 | |
294 // Same as PostWorkerTask but allows specification of the shutdown behavior. | 281 // Same as PostWorkerTask but allows specification of the shutdown behavior. |
295 bool PostWorkerTaskWithShutdownBehavior( | 282 bool PostWorkerTaskWithShutdownBehavior( |
296 const tracked_objects::Location& from_here, | 283 const tracked_objects::Location& from_here, |
297 OnceClosure task, | 284 OnceClosure task, |
298 WorkerShutdown shutdown_behavior); | 285 WorkerShutdown shutdown_behavior); |
299 | 286 |
300 // Like PostWorkerTask above, but provides sequencing semantics. This means | 287 // Like PostWorkerTask above, but provides sequencing semantics. This means |
301 // that tasks posted with the same sequence token (see GetSequenceToken()) | 288 // that tasks posted with the same sequence token (see GetSequenceToken()) |
302 // are guaranteed to execute in order. This is useful in cases where you're | 289 // are guaranteed to execute in order. This is useful in cases where you're |
303 // doing operations that may depend on previous ones, like appending to a | 290 // doing operations that may depend on previous ones, like appending to a |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 // Avoid pulling in too many headers by putting (almost) everything | 396 // Avoid pulling in too many headers by putting (almost) everything |
410 // into |inner_|. | 397 // into |inner_|. |
411 const std::unique_ptr<Inner> inner_; | 398 const std::unique_ptr<Inner> inner_; |
412 | 399 |
413 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool); | 400 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool); |
414 }; | 401 }; |
415 | 402 |
416 } // namespace base | 403 } // namespace base |
417 | 404 |
418 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_ | 405 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_ |
OLD | NEW |