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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // pool.PostSequencedWorkerTask(token, SequencedWorkerPool::SKIP_ON_SHUTDOWN, | 50 // pool.PostSequencedWorkerTask(token, SequencedWorkerPool::SKIP_ON_SHUTDOWN, |
51 // FROM_HERE, base::Bind(...)); | 51 // FROM_HERE, base::Bind(...)); |
52 // | 52 // |
53 // You can make named sequence tokens to make it easier to share a token | 53 // You can make named sequence tokens to make it easier to share a token |
54 // across different components. | 54 // across different components. |
55 // | 55 // |
56 // You can also post tasks to the pool without ordering using PostWorkerTask. | 56 // You can also post tasks to the pool without ordering using PostWorkerTask. |
57 // These will be executed in an unspecified order. The order of execution | 57 // These will be executed in an unspecified order. The order of execution |
58 // between tasks with different sequence tokens is also unspecified. | 58 // between tasks with different sequence tokens is also unspecified. |
59 // | 59 // |
60 // This class is designed to be leaked on shutdown to allow the | 60 // This class may be leaked on shutdown to facilitate fast shutdown. The |
61 // CONTINUE_ON_SHUTDOWN behavior to be implemented. To enforce the | 61 // expected usage, however, is to call Shutdown(), which correctly accounts |
62 // BLOCK_SHUTDOWN behavior, you must call Shutdown() which will wait until | 62 // for CONTINUE_ON_SHUTDOWN behavior and is required for BLOCK_SHUTDOWN |
63 // the necessary tasks have completed. | 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 class BASE_EXPORT SequencedWorkerPool : public TaskRunner { | 72 class BASE_EXPORT SequencedWorkerPool : public TaskRunner { |
73 public: | 73 public: |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 // Avoid pulling in too many headers by putting (almost) everything | 333 // Avoid pulling in too many headers by putting (almost) everything |
334 // into |inner_|. | 334 // into |inner_|. |
335 const scoped_ptr<Inner> inner_; | 335 const scoped_ptr<Inner> inner_; |
336 | 336 |
337 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool); | 337 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool); |
338 }; | 338 }; |
339 | 339 |
340 } // namespace base | 340 } // namespace base |
341 | 341 |
342 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_ | 342 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_ |
OLD | NEW |