Chromium Code Reviews| Index: base/task.h |
| diff --git a/base/task.h b/base/task.h |
| index b698576ef899e3d4c0faad1c8845f13b22bbe4e1..c87629d03b36d06e6101eab49282c7046b3d0e45 100644 |
| --- a/base/task.h |
| +++ b/base/task.h |
| @@ -546,4 +546,21 @@ inline Task* NewRunnableFunction(Function function, const A& a, const B& b, |
| function, MakeTuple(a, b, c, d, e, f, g, h)); |
| } |
| +// ScopedTaskRunner is akin to scoped_ptr for Tasks. It ensures that the Task |
| +// is executed and deleted no matter how the current scope exits. |
| +class ScopedTaskRunner { |
|
awong
2011/05/26 02:51:38
Should this be thrown into the namespace base? I
brettw
2011/05/26 17:17:22
I agree that using the base namespace is a good id
Wez
2011/05/26 18:48:21
Done.
|
| + public: |
| + // Takes ownership of the task. |
| + explicit ScopedTaskRunner(Task* task) : task_(task) {} |
|
awong
2011/05/26 02:51:38
Since we're out-of-lining the destructor, might as
Wez
2011/05/26 18:48:21
Done.
|
| + |
| + ~ScopedTaskRunner(); |
| + |
| + Task* release() { Task* tmp = task_; task_ = NULL; return tmp; } |
|
brettw
2011/05/26 17:17:22
I think out-of-lining is also good for this (shoul
Wez
2011/05/26 18:48:21
Done.
|
| + |
| + private: |
| + Task* task_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ScopedTaskRunner); |
|
scherkus (not reviewing)
2011/05/26 02:57:16
micro-nit: DISALLOW_IMPLICIT_CONSTRUCTORS
Wez
2011/05/26 18:48:21
Done.
|
| +}; |
| + |
| #endif // BASE_TASK_H_ |