OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_TASK_H_ | 5 #ifndef BASE_TASK_H_ |
6 #define BASE_TASK_H_ | 6 #define BASE_TASK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/base_api.h" | 9 #include "base/base_api.h" |
10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 | 539 |
540 template <class Function, class A, class B, class C, class D, class E, | 540 template <class Function, class A, class B, class C, class D, class E, |
541 class F, class G, class H> | 541 class F, class G, class H> |
542 inline Task* NewRunnableFunction(Function function, const A& a, const B& b, | 542 inline Task* NewRunnableFunction(Function function, const A& a, const B& b, |
543 const C& c, const D& d, const E& e, const F& f, | 543 const C& c, const D& d, const E& e, const F& f, |
544 const G& g, const H& h) { | 544 const G& g, const H& h) { |
545 return new RunnableFunction<Function, Tuple8<A, B, C, D, E, F, G, H> >( | 545 return new RunnableFunction<Function, Tuple8<A, B, C, D, E, F, G, H> >( |
546 function, MakeTuple(a, b, c, d, e, f, g, h)); | 546 function, MakeTuple(a, b, c, d, e, f, g, h)); |
547 } | 547 } |
548 | 548 |
| 549 namespace base { |
| 550 |
| 551 // ScopedTaskRunner is akin to scoped_ptr for Tasks. It ensures that the Task |
| 552 // is executed and deleted no matter how the current scope exits. |
| 553 class BASE_API ScopedTaskRunner { |
| 554 public: |
| 555 // Takes ownership of the task. |
| 556 explicit ScopedTaskRunner(Task* task); |
| 557 ~ScopedTaskRunner(); |
| 558 |
| 559 Task* Release(); |
| 560 |
| 561 private: |
| 562 Task* task_; |
| 563 |
| 564 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedTaskRunner); |
| 565 }; |
| 566 |
| 567 } // namespace base |
| 568 |
549 #endif // BASE_TASK_H_ | 569 #endif // BASE_TASK_H_ |
OLD | NEW |