-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExceptionManager.cpp
74 lines (55 loc) · 1.36 KB
/
ExceptionManager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "BaseLib/ExceptionManager.h"
#include "BaseLib/Exception.h"
#include "BaseLib/CommonDefines.h"
#include "BaseLib/MutexLocker.h"
using namespace std;
namespace BaseLib
{
ExceptionManager* ExceptionManager::exceptionManager_ = NULL;
ExceptionManager::ExceptionManager(std::string name)
: Thread(name)
, ObjectBase(name)
{
}
ExceptionManager::~ExceptionManager()
{
}
void ExceptionManager::run()
{
IDEBUG() << "running";
while(true)
{
msleep(1000);
}
}
ExceptionManager* ExceptionManager::getOrCreateExceptionManager()
{
static Mutex staticMutex;
MutexLocker lock(&staticMutex);
if(ExceptionManager::exceptionManager_ == NULL)
ExceptionManager::exceptionManager_ = new ExceptionManager();
return ExceptionManager::exceptionManager_;
}
bool ExceptionManager::AddObject(Exception *base)
{
MutexLocker lock(&managerMutex_);
if(setException_.count(base) >= 1)
{
IDEBUG() << "ERROR! Exception already present in ExceptionManager!";
return false;
}
setException_.insert(base);
return true;
}
bool ExceptionManager::RemoveObject(Exception *base)
{
MutexLocker lock(&managerMutex_);
if(setException_.count(base) <= 0)
{
IDEBUG() << "ERROR! already remomved from ExceptionManager!";
return false;
}
setException_.erase(base);
return true;
}
}