1#include "../Mutex.h"
2
3#include <stdio.h>
4#include <stdlib.h>
5
6using namespace muduo;
7
8void someFunctionMayCallExit()
9{
10  exit(1);
11}
12
13class GlobalObject
14{
15 public:
16  void doit()
17  {
18    MutexLockGuard lock(mutex_);
19    someFunctionMayCallExit();
20  }
21
22  ~GlobalObject()
23  {
24    printf("GlobalObject:~GlobalObject\n");
25    MutexLockGuard g(mutex_);
26    // clean up
27    printf("GlobalObject:~GlobalObject cleanning\n");
28  }
29
30 private:
31  MutexLock mutex_;
32};
33
34GlobalObject g_obj;
35
36int main()
37{
38  g_obj.doit();
39}
40