8000 thread safety · lethalbrains/arangodb@4958086 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4958086

Browse files
committed
thread safety
1 parent 974398e commit 4958086

File tree

3 files changed

+14
-41
lines changed

3 files changed

+14
-41
lines changed

arangod/Cluster/ApplicationCluster.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,18 @@ ApplicationCluster::ApplicationCluster (TRI_server_t* server,
8484
_enableCluster(false),
8585
_disableHeartbeat(false) {
8686

87-
TRI_ASSERT(_dispatcher != 0);
87+
TRI_ASSERT(_dispatcher != nullptr);
8888
}
8989

9090
////////////////////////////////////////////////////////////////////////////////
9191
/// @brief destructor
9292
////////////////////////////////////////////////////////////////////////////////
9393

9494
ApplicationCluster::~ApplicationCluster () {
95-
if (_heartbeat != 0) {
95+
if (_heartbeat != nullptr) {
9696
// flat line.....
9797
delete _heartbeat;
9898
}
99-
100-
ServerState::cleanup();
10199
}
102100

103101
// -----------------------------------------------------------------------------
@@ -133,10 +131,6 @@ void ApplicationCluster::setupOptions (std::map<std::string, basics::ProgramOpti
133131
////////////////////////////////////////////////////////////////////////////////
134132

135133
bool ApplicationCluster::prepare () {
136-
137-
// initialise ServerState library
138-
ServerState::initialise();
139-
140134
8000 // set authentication data
141135
ServerState::instance()->setAuthentication(_username, _password);
142136

arangod/Cluster/ServerState.cpp

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ using namespace std;
3939
using namespace triagens::arango;
4040
using namespace triagens::basics;
4141

42+
// -----------------------------------------------------------------------------
43+
// --SECTION-- static variables
44+
// -----------------------------------------------------------------------------
45+
46+
////////////////////////////////////////////////////////////////////////////////
47+
/// @brief single instance of ServerState - will live as long as the server is
48+
/// running
49+
////////////////////////////////////////////////////////////////////////////////
50+
51+
ServerState Instance;
52+
4253
// -----------------------------------------------------------------------------
4354
// --SECTION-- ServerState
4455
// -----------------------------------------------------------------------------
@@ -84,27 +95,7 @@ ServerState::~ServerState () {
8495
////////////////////////////////////////////////////////////////////////////////
8596

8697
ServerState* ServerState::instance () {
87-
static ServerState* Instance = new ServerState();
88-
return Instance;
89-
}
90-
91-
////////////////////////////////////////////////////////////////////////////////
92-
/// @brief initialise the server state singleton object
93-
////////////////////////////////////////////////////////////////////////////////
94-
95-
void ServerState::initialise () {
96-
instance();
97-
}
98-
99-
////////////////////////////////////////////////////////////////////////////////
100-
/// @brief cleanup function to call once when shutting down
101-
////////////////////////////////////////////////////////////////////////////////
102-
103-
void ServerState::cleanup () {
104-
auto i = instance();
105-
TRI_ASSERT(i != nullptr);
106-
107-
delete i;
98+
return &Instance;
10899
}
109100

110101
////////////////////////////////////////////////////////////////////////////////

arangod/Cluster/ServerState.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,6 @@ namespace triagens {
108108

109109
static ServerState* instance ();
110110

111-
////////////////////////////////////////////////////////////////////////////////
112-
/// @brief initialise function to call once when still single-threaded
113-
////////////////////////////////////////////////////////////////////////////////
114-
115-
static void initialise ();
116-
117-
////////////////////////////////////////////////////////////////////////////////
118-
/// @brief cleanup function to call once when shutting down
119-
////////////////////////////////////////////////////////////////////////////////
120-
121-
static void cleanup ();
122-
123111
////////////////////////////////////////////////////////////////////////////////
124112
/// @brief get the string representation of a role
125113
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)
0