| 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 // Spuriously signal that there is work to be done. | 313 // Spuriously signal that there is work to be done. |
| 314 void SignalHasWorkForTesting(); | 314 void SignalHasWorkForTesting(); |
| 315 | 315 |
| 316 // Implements the worker pool shutdown. This should be called during app | 316 // Implements the worker pool shutdown. This should be called during app |
| 317 // shutdown, and will discard/join with appropriate tasks before returning. | 317 // shutdown, and will discard/join with appropriate tasks before returning. |
| 318 // After this call, subsequent calls to post tasks will fail. | 318 // After this call, subsequent calls to post tasks will fail. |
| 319 // | 319 // |
| 320 // Must be called from the same thread this object was constructed on. | 320 // Must be called from the same thread this object was constructed on. |
| 321 void Shutdown() { Shutdown(0); } | 321 void Shutdown() { Shutdown(0); } |
| 322 | 322 |
| 323 // A variant that allows an arbitrary number of new blocking tasks to | 323 // A variant that allows an arbitrary number of new blocking tasks to be |
| 324 // be posted during shutdown from within tasks that execute during shutdown. | 324 // posted during shutdown. The tasks cannot be posted within the execution |
| 325 // Only tasks designated as BLOCKING_SHUTDOWN will be allowed, and only if | 325 // context of tasks whose shutdown behavior is not BLOCKING_SHUTDOWN. Once |
| 326 // posted by tasks that are not designated as CONTINUE_ON_SHUTDOWN. Once | |
| 327 // the limit is reached, subsequent calls to post task fail in all cases. | 326 // the limit is reached, subsequent calls to post task fail in all cases. |
| 328 // | |
| 329 // Must be called from the same thread this object was constructed on. | 327 // Must be called from the same thread this object was constructed on. |
| 330 void Shutdown(int max_new_blocking_tasks_after_shutdown); | 328 void Shutdown(int max_new_blocking_tasks_after_shutdown); |
| 331 | 329 |
| 332 // Check if Shutdown was called for given threading pool. This method is used | 330 // Check if Shutdown was called for given threading pool. This method is used |
| 333 // for aborting time consuming operation to avoid blocking shutdown. | 331 // for aborting time consuming operation to avoid blocking shutdown. |
| 334 // | 332 // |
| 335 // Can be called from any thread. | 333 // Can be called from any thread. |
| 336 bool IsShutdownInProgress(); | 334 bool IsShutdownInProgress(); |
| 337 | 335 |
| 338 protected: | 336 protected: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 352 // Avoid pulling in too many headers by putting (almost) everything | 350 // Avoid pulling in too many headers by putting (almost) everything |
| 353 // into |inner_|. | 351 // into |inner_|. |
| 354 const scoped_ptr<Inner> inner_; | 352 const scoped_ptr<Inner> inner_; |
| 355 | 353 |
| 356 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool); | 354 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool); |
| 357 }; | 355 }; |
| 358 | 356 |
| 359 } // namespace base | 357 } // namespace base |
| 360 | 358 |
| 361 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_ | 359 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_ |
| OLD | NEW |