Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: base/at_exit.h

Issue 6725001: Base: First pass at having base.dll: definition of (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/base.gypi » ('j') | base/base_api.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_AT_EXIT_H_ 5 #ifndef BASE_AT_EXIT_H_
6 #define BASE_AT_EXIT_H_ 6 #define BASE_AT_EXIT_H_
7 #pragma once 7 #pragma once
8 8
9 #include <stack> 9 #include <stack>
10 10
11 #include "base/base_api.h"
11 #include "base/basictypes.h" 12 #include "base/basictypes.h"
12 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
13 14
14 namespace base { 15 namespace base {
15 16
16 // This class provides a facility similar to the CRT atexit(), except that 17 // This class provides a facility similar to the CRT atexit(), except that
17 // we control when the callbacks are executed. Under Windows for a DLL they 18 // we control when the callbacks are executed. Under Windows for a DLL they
18 // happen at a really bad time and under the loader lock. This facility is 19 // happen at a really bad time and under the loader lock. This facility is
19 // mostly used by base::Singleton. 20 // mostly used by base::Singleton.
20 // 21 //
21 // The usage is simple. Early in the main() or WinMain() scope create an 22 // The usage is simple. Early in the main() or WinMain() scope create an
22 // AtExitManager object on the stack: 23 // AtExitManager object on the stack:
23 // int main(...) { 24 // int main(...) {
24 // base::AtExitManager exit_manager; 25 // base::AtExitManager exit_manager;
25 // 26 //
26 // } 27 // }
27 // When the exit_manager object goes out of scope, all the registered 28 // When the exit_manager object goes out of scope, all the registered
28 // callbacks and singleton destructors will be called. 29 // callbacks and singleton destructors will be called.
29 30
30 class AtExitManager { 31 class BASE_API AtExitManager {
31 public: 32 public:
32 typedef void (*AtExitCallbackType)(void*); 33 typedef void (*AtExitCallbackType)(void*);
33 34
34 AtExitManager(); 35 AtExitManager();
35 36
36 // The dtor calls all the registered callbacks. Do not try to register more 37 // The dtor calls all the registered callbacks. Do not try to register more
37 // callbacks after this point. 38 // callbacks after this point.
38 ~AtExitManager(); 39 ~AtExitManager();
39 40
40 // Registers the specified function to be called at exit. The prototype of 41 // Registers the specified function to be called at exit. The prototype of
(...skipping 29 matching lines...) Expand all
70 #if defined(UNIT_TEST) 71 #if defined(UNIT_TEST)
71 class ShadowingAtExitManager : public AtExitManager { 72 class ShadowingAtExitManager : public AtExitManager {
72 public: 73 public:
73 ShadowingAtExitManager() : AtExitManager(true) {} 74 ShadowingAtExitManager() : AtExitManager(true) {}
74 }; 75 };
75 #endif // defined(UNIT_TEST) 76 #endif // defined(UNIT_TEST)
76 77
77 } // namespace base 78 } // namespace base
78 79
79 #endif // BASE_AT_EXIT_H_ 80 #endif // BASE_AT_EXIT_H_
OLDNEW
« no previous file with comments | « no previous file | base/base.gypi » ('j') | base/base_api.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698