Chromium Code Reviews| Index: base/at_exit.h |
| =================================================================== |
| --- base/at_exit.h (revision 99168) |
| +++ base/at_exit.h (working copy) |
| @@ -10,8 +10,11 @@ |
| #include "base/base_export.h" |
| #include "base/basictypes.h" |
| +#include "base/memory/linked_ptr.h" |
| #include "base/synchronization/lock.h" |
| +class Task; |
| + |
| namespace base { |
| // This class provides a facility similar to the CRT atexit(), except that |
| @@ -39,9 +42,13 @@ |
| ~AtExitManager(); |
| // Registers the specified function to be called at exit. The prototype of |
| - // the callback function is void func(). |
| + // the callback function is void func(void*). |
| static void RegisterCallback(AtExitCallbackType func, void* param); |
| + // Registers the specified task to be called at exit. The task is deleted |
| + // after it runs. |
| + static void RegisterTask(Task* task); |
|
darin (slow to review)
2011/09/01 23:35:44
how about using base::Closure instead?
|
| + |
| // Calls the functions registered with RegisterCallback in LIFO order. It |
| // is possible to register new callbacks after calling this function. |
| static void ProcessCallbacksNow(); |
| @@ -54,15 +61,8 @@ |
| explicit AtExitManager(bool shadow); |
| private: |
| - struct CallbackAndParam { |
| - CallbackAndParam(AtExitCallbackType func, void* param) |
| - : func_(func), param_(param) { } |
| - AtExitCallbackType func_; |
| - void* param_; |
| - }; |
| - |
| base::Lock lock_; |
| - std::stack<CallbackAndParam> stack_; |
| + std::stack<linked_ptr<Task> > stack_; |
| AtExitManager* next_manager_; // Stack of managers to allow shadowing. |
| DISALLOW_COPY_AND_ASSIGN(AtExitManager); |