-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathNbModule.cpp
165 lines (148 loc) · 5.56 KB
/
NbModule.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
//==============================================================================
//
// NbModule.cpp
//
// Copyright (C) 2013-2022 Greg Utas
//
// This file is part of the Robust Services Core (RSC).
//
// RSC is free software: you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the Free Software
// Foundation, either version 3 of the License, or (at your option) any later
// version.
//
// RSC is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details.
//
// You should have received a copy of the GNU General Public License along
// with RSC. If not, see <http://www.gnu.org/licenses/>.
//
#include "NbModule.h"
#include "AlarmRegistry.h"
#include "CfgParmRegistry.h"
#include "CinThread.h"
#include "ClassRegistry.h"
#include "CliRegistry.h"
#include "CliThread.h"
#include "CoutThread.h"
#include "DaemonRegistry.h"
#include "Debug.h"
#include "DeferredRegistry.h"
#include "DeferredThread.h"
#include "Duration.h"
#include "Element.h"
#include "FileThread.h"
#include "InitFlags.h"
#include "LogBufferRegistry.h"
#include "LogGroupRegistry.h"
#include "LogThread.h"
#include "Memory.h"
#include "ModuleRegistry.h"
#include "NbIncrement.h"
#include "NbLogs.h"
#include "NbPools.h"
#include "ObjectPoolAudit.h"
#include "ObjectPoolRegistry.h"
#include "PosixSignalRegistry.h"
#include "Singleton.h"
#include "Singletons.h"
#include "StatisticsRegistry.h"
#include "StatisticsThread.h"
#include "SymbolRegistry.h"
#include "SysStackTrace.h"
#include "ThisThread.h"
#include "ThreadAdmin.h"
#include "ThreadRegistry.h"
#include "TraceBuffer.h"
//------------------------------------------------------------------------------
namespace NodeBase
{
NbModule::NbModule() : Module()
{
Debug::ft("NbModule.ctor");
Singleton<ModuleRegistry>::Instance()->BindModule(*this);
}
//------------------------------------------------------------------------------
NbModule::~NbModule()
{
Debug::ftnt("NbModule.dtor");
}
//------------------------------------------------------------------------------
void NbModule::Patch(sel_t selector, void* arguments)
{
Module::Patch(selector, arguments);
}
//------------------------------------------------------------------------------
void NbModule::Shutdown(RestartLevel level)
{
Debug::ft("NbModule.Shutdown");
Singleton<NbIncrement>::Instance()->Shutdown(level);
Singleton<SymbolRegistry>::Instance()->Shutdown(level);
Singleton<CliRegistry>::Instance()->Shutdown(level);
Singleton<Element>::Instance()->Shutdown(level);
Singleton<ClassRegistry>::Instance()->Shutdown(level);
Singleton<ThreadAdmin>::Instance()->Shutdown(level);
Singleton<ObjectPoolRegistry>::Instance()->Shutdown(level);
Singleton<DeferredRegistry>::Instance()->Shutdown(level);
Singleton<DaemonRegistry>::Instance()->Shutdown(level);
Singleton<CfgParmRegistry>::Instance()->Shutdown(level);
Singleton<LogGroupRegistry>::Instance()->Shutdown(level);
Singleton<AlarmRegistry>::Instance()->Shutdown(level);
Singleton<StatisticsRegistry>::Instance()->Shutdown(level);
Singleton<ThreadRegistry>::Instance()->Shutdown(level);
Singleton<LogBufferRegistry>::Instance()->Shutdown(level);
Singleton<PosixSignalRegistry>::Instance()->Shutdown(level);
Singleton<TraceBuffer>::Instance()->Shutdown(level);
SysStackTrace::Shutdown(level);
Memory::Shutdown();
Singletons::Instance()->Shutdown(level);
}
//------------------------------------------------------------------------------
void NbModule::Startup(RestartLevel level)
{
Debug::ft("NbModule.Startup");
// Create/start singletons. Some of these already exist as a
// result of creating RootThread, but their Startup functions
// must be invoked.
//
Singleton<PosixSignalRegistry>::Instance()->Startup(level);
Singleton<LogBufferRegistry>::Instance()->Startup(level);
Singleton<ThreadRegistry>::Instance()->Startup(level);
Singleton<StatisticsRegistry>::Instance()->Startup(level);
Singleton<AlarmRegistry>::Instance()->Startup(level);
Singleton<LogGroupRegistry>::Instance()->Startup(level);
CreateNbLogs(level);
Singleton<CfgParmRegistry>::Instance()->Startup(level);
Singleton<DaemonRegistry>::Instance()->Startup(level);
Singleton<DeferredRegistry>::Instance()->Startup(level);
Singleton<ObjectPoolRegistry>::Instance()->Startup(level);
Singleton<ThreadAdmin>::Instance()->Startup(level);
Singleton<MsgBufferPool>::Instance()->Startup(level);
Singleton<ClassRegistry>::Instance()->Startup(level);
Singleton<Element>::Instance()->Startup(level);
Singleton<CliRegistry>::Instance()->Startup(level);
Singleton<SymbolRegistry>::Instance()->Startup(level);
Singleton<NbIncrement>::Instance()->Startup(level);
// See if we're supposed to cause an initialization timeout.
//
if(InitFlags::CauseTimeout())
{
ThisThread::Pause(TIMEOUT_NEVER);
}
// Create/start threads.
//
Singleton<FileThread>::Instance()->Startup(level);
Singleton<CoutThread>::Instance()->Startup(level);
Singleton<CinThread>::Instance()->Startup(level);
Singleton<ObjectPoolAudit>::Instance()->Startup(level);
Singleton<StatisticsThread>::Instance()->Startup(level);
Singleton<LogThread>::Instance()->Startup(level);
Singleton<DeferredThread>::Instance()->Startup(level);
Singleton<CliThread>::Instance()->Startup(level);
// Enable optional modules.
//
Singleton<ModuleRegistry>::Instance()->EnableModules();
}
}