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

Skip to content

Commit 9ff4e79

Browse files
committed
thread-safety
1 parent 4958086 commit 9ff4e79

File tree

4 files changed

+22
-42
lines changed

4 files changed

+22
-42
lines changed

arangod/Cluster/ApplicationCluster.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,6 @@ bool ApplicationCluster::prepare () {
208208
ServerState::instance()->setAddress(_myAddress);
209209
}
210210

211-
// initialise ClusterInfo library
212-
ClusterInfo::initialise();
213-
214211
// initialise ClusterComm library
215212
ClusterComm::initialise();
216213

@@ -516,7 +513,6 @@ void ApplicationCluster::stop () {
516513
}
517514

518515
ClusterComm::cleanup();
519-
ClusterInfo::cleanup();
520516
AgencyComm::cleanup();
521517
}
522518

arangod/Cluster/ClusterInfo.cpp

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@
4545
using namespace std;
4646
using namespace triagens::arango;
4747
using triagens::basics::JsonHelper;
48+
49+
// -----------------------------------------------------------------------------
50+
// --SECTION-- static variables
51+
// -----------------------------------------------------------------------------
52+
53+
////////////////////////////////////////////////////////////////////////////////
54+
/// @brief single instance of ClusterInfo - will live as long as the server is
55+
/// running
56+
////////////////////////////////////////////////////////////////////////////////
57+
58+
static ClusterInfo Instance;
4859

4960
// -----------------------------------------------------------------------------
5061
// --SECTION-- private functions
@@ -243,27 +254,7 @@ void CollectionInfoCurrent::copyAllJsons () {
243254
////////////////////////////////////////////////////////////////////////////////
244255

245256
ClusterInfo* ClusterInfo::instance () {
246-
static ClusterInfo* Instance = new ClusterInfo();
247-
return Instance;
248-
}
249-
250-
////////////////////////////////////////////////////////////////////////////////
251-
/// @brief initialise the cluster info singleton object
252-
////////////////////////////////////////////////////////////////////////////////
253-
254-
void ClusterInfo::initialise () {
255-
instance();
256-
}
257-
258-
////////////////////////////////////////////////////////////////////////////////
259-
/// @brief cleanup function to call once when shutting down
260-
////////////////////////////////////////////////////////////////////////////////
261-
262-
void ClusterInfo::cleanup () {
263-
auto i = instance();
264-
TRI_ASSERT(i != nullptr);
265-
266-
delete i;
257+
return &Instance;
267258
}
268259

269260
////////////////////////////////////////////////////////////////////////////////

arangod/Cluster/ClusterInfo.h

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -716,16 +716,21 @@ namespace triagens {
716716
/// new instances or copy them, except we ourselves.
717717
////////////////////////////////////////////////////////////////////////////////
718718

719+
ClusterInfo (ClusterInfo const&) = delete; // not implemented
720+
ClusterInfo& operator= (ClusterInfo const&) = delete; // not implemented
721+
722+
public:
723+
724+
////////////////////////////////////////////////////////////////////////////////
725+
/// @brief creates library
726+
////////////////////////////////////////////////////////////////////////////////
727+
719728
ClusterInfo ();
720-
ClusterInfo (ClusterInfo const&); // not implemented
721-
void operator= (ClusterInfo const&); // not implemented
722729

723730
////////////////////////////////////////////////////////////////////////////////
724731
/// @brief shuts down library
725732
////////////////////////////////////////////////////////////////////////////////
726733

727-
public:
728-
729734
~ClusterInfo ();
730735

731736
// -----------------------------------------------------------------------------
@@ -740,18 +745,6 @@ namespace triagens {
740745

741746
static ClusterInfo* instance ();
742747

743-
////////////////////////////////////////////////////////////////////////////////
744-
/// @brief initialise function to call once when still single-threaded
745-
////////////////////////////////////////////////////////////////////////////////
746-
747-
static void initialise ();
748-
749-
////////////////////////////////////////////////////////////////////////////////
750-
/// @brief cleanup function to call once when shutting down
751-
////////////////////////////////////////////////////////////////////////////////
752-
753-
static void cleanup ();
754-
755748
// -----------------------------------------------------------------------------
756749
// --SECTION-- public methods
757750
// -----------------------------------------------------------------------------

arangod/Cluster/ServerState.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ using namespace triagens::basics;
4848
/// running
4949
////////////////////////////////////////////////////////////////////////////////
5050

51-
ServerState Instance;
51+
static ServerState Instance;
5252

5353
// -----------------------------------------------------------------------------
5454
// --SECTION-- ServerState

0 commit comments

Comments
 (0)
0