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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 283 |
284 // Same as PostSequencedWorkerTask but allows specification of the shutdown | 284 // Same as PostSequencedWorkerTask but allows specification of the shutdown |
285 // behavior. | 285 // behavior. |
286 bool PostSequencedWorkerTaskWithShutdownBehavior( | 286 bool PostSequencedWorkerTaskWithShutdownBehavior( |
287 SequenceToken sequence_token, | 287 SequenceToken sequence_token, |
288 const tracked_objects::Location& from_here, | 288 const tracked_objects::Location& from_here, |
289 const Closure& task, | 289 const Closure& task, |
290 WorkerShutdown shutdown_behavior); | 290 WorkerShutdown shutdown_behavior); |
291 | 291 |
292 // TaskRunner implementation. Forwards to PostDelayedWorkerTask(). | 292 // TaskRunner implementation. Forwards to PostDelayedWorkerTask(). |
293 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, | 293 bool PostDelayedTask(const tracked_objects::Location& from_here, |
294 const Closure& task, | 294 const Closure& task, |
295 TimeDelta delay) OVERRIDE; | 295 TimeDelta delay) override; |
296 virtual bool RunsTasksOnCurrentThread() const OVERRIDE; | 296 bool RunsTasksOnCurrentThread() const override; |
297 | 297 |
298 // Returns true if the current thread is processing a task with the given | 298 // Returns true if the current thread is processing a task with the given |
299 // sequence_token. | 299 // sequence_token. |
300 bool IsRunningSequenceOnCurrentThread(SequenceToken sequence_token) const; | 300 bool IsRunningSequenceOnCurrentThread(SequenceToken sequence_token) const; |
301 | 301 |
302 // Blocks until all pending tasks are complete. This should only be called in | 302 // Blocks until all pending tasks are complete. This should only be called in |
303 // unit tests when you want to validate something that should have happened. | 303 // unit tests when you want to validate something that should have happened. |
304 // This will not flush delayed tasks; delayed tasks get deleted. | 304 // This will not flush delayed tasks; delayed tasks get deleted. |
305 // | 305 // |
306 // Note that calling this will not prevent other threads from posting work to | 306 // Note that calling this will not prevent other threads from posting work to |
(...skipping 24 matching lines...) Expand all Loading... |
331 | 331 |
332 // Check if Shutdown was called for given threading pool. This method is used | 332 // Check if Shutdown was called for given threading pool. This method is used |
333 // for aborting time consuming operation to avoid blocking shutdown. | 333 // for aborting time consuming operation to avoid blocking shutdown. |
334 // | 334 // |
335 // Can be called from any thread. | 335 // Can be called from any thread. |
336 bool IsShutdownInProgress(); | 336 bool IsShutdownInProgress(); |
337 | 337 |
338 protected: | 338 protected: |
339 virtual ~SequencedWorkerPool(); | 339 virtual ~SequencedWorkerPool(); |
340 | 340 |
341 virtual void OnDestruct() const OVERRIDE; | 341 void OnDestruct() const override; |
342 | 342 |
343 private: | 343 private: |
344 friend class RefCountedThreadSafe<SequencedWorkerPool>; | 344 friend class RefCountedThreadSafe<SequencedWorkerPool>; |
345 friend class DeleteHelper<SequencedWorkerPool>; | 345 friend class DeleteHelper<SequencedWorkerPool>; |
346 | 346 |
347 class Inner; | 347 class Inner; |
348 class Worker; | 348 class Worker; |
349 | 349 |
350 const scoped_refptr<MessageLoopProxy> constructor_message_loop_; | 350 const scoped_refptr<MessageLoopProxy> constructor_message_loop_; |
351 | 351 |
352 // Avoid pulling in too many headers by putting (almost) everything | 352 // Avoid pulling in too many headers by putting (almost) everything |
353 // into |inner_|. | 353 // into |inner_|. |
354 const scoped_ptr<Inner> inner_; | 354 const scoped_ptr<Inner> inner_; |
355 | 355 |
356 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool); | 356 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool); |
357 }; | 357 }; |
358 | 358 |
359 } // namespace base | 359 } // namespace base |
360 | 360 |
361 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_ | 361 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_ |
OLD | NEW |