| 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 <cstddef> | 8 #include <cstddef> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // for CONTINUE_ON_SHUTDOWN behavior and is required for BLOCK_SHUTDOWN | 62 // for CONTINUE_ON_SHUTDOWN behavior and is required for BLOCK_SHUTDOWN |
| 63 // behavior. | 63 // behavior. |
| 64 // | 64 // |
| 65 // Implementation note: This does not use a base::WorkerPool since that does | 65 // Implementation note: This does not use a base::WorkerPool since that does |
| 66 // not enforce shutdown semantics or allow us to specify how many worker | 66 // not enforce shutdown semantics or allow us to specify how many worker |
| 67 // threads to run. For the typical use case of random background work, we don't | 67 // threads to run. For the typical use case of random background work, we don't |
| 68 // necessarily want to be super aggressive about creating threads. | 68 // necessarily want to be super aggressive about creating threads. |
| 69 // | 69 // |
| 70 // Note that SequencedWorkerPool is RefCountedThreadSafe (inherited | 70 // Note that SequencedWorkerPool is RefCountedThreadSafe (inherited |
| 71 // from TaskRunner). | 71 // from TaskRunner). |
| 72 // |
| 73 // Test-only code should wrap this in a base::SequencedWorkerPoolOwner to avoid |
| 74 // memory leaks. See http://crbug.com/273800 |
| 72 class BASE_EXPORT SequencedWorkerPool : public TaskRunner { | 75 class BASE_EXPORT SequencedWorkerPool : public TaskRunner { |
| 73 public: | 76 public: |
| 74 // Defines what should happen to a task posted to the worker pool on | 77 // Defines what should happen to a task posted to the worker pool on |
| 75 // shutdown. | 78 // shutdown. |
| 76 enum WorkerShutdown { | 79 enum WorkerShutdown { |
| 77 // Tasks posted with this mode which have not run at shutdown will be | 80 // Tasks posted with this mode which have not run at shutdown will be |
| 78 // deleted rather than run, and any tasks with this mode running at | 81 // deleted rather than run, and any tasks with this mode running at |
| 79 // shutdown will be ignored (the worker thread will not be joined). | 82 // shutdown will be ignored (the worker thread will not be joined). |
| 80 // | 83 // |
| 81 // This option provides a nice way to post stuff you don't want blocking | 84 // This option provides a nice way to post stuff you don't want blocking |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 // Avoid pulling in too many headers by putting (almost) everything | 352 // Avoid pulling in too many headers by putting (almost) everything |
| 350 // into |inner_|. | 353 // into |inner_|. |
| 351 const scoped_ptr<Inner> inner_; | 354 const scoped_ptr<Inner> inner_; |
| 352 | 355 |
| 353 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool); | 356 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool); |
| 354 }; | 357 }; |
| 355 | 358 |
| 356 } // namespace base | 359 } // namespace base |
| 357 | 360 |
| 358 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_ | 361 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_ |
| OLD | NEW |