summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2019-01-28 22:25:44 -0500
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2019-01-30 18:31:39 -0500
commite311d83680e698ac485271968a6d2355a9438e38 (patch)
treea0d6627611e0ac9aab6fac69e5824886c71affe5 /src
parent368eb15160d51e53a42e4e0411a5572e513941cc (diff)
downloadmongo-e311d83680e698ac485271968a6d2355a9438e38.tar.gz
SERVER-39240 Make WriteConcernOptions timeout constants to be constexpr
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/write_concern_options.cpp14
-rw-r--r--src/mongo/db/write_concern_options.h14
-rw-r--r--src/mongo/s/catalog/sharding_catalog_client.cpp3
3 files changed, 16 insertions, 15 deletions
diff --git a/src/mongo/db/write_concern_options.cpp b/src/mongo/db/write_concern_options.cpp
index 96b3af194be..fe2a1a4a1be 100644
--- a/src/mongo/db/write_concern_options.cpp
+++ b/src/mongo/db/write_concern_options.cpp
@@ -62,10 +62,10 @@ constexpr StringData kWElectionIdFieldName = "wElectionId"_sd;
} // namespace
-const int WriteConcernOptions::kNoTimeout(0);
-const int WriteConcernOptions::kNoWaiting(-1);
+constexpr int WriteConcernOptions::kNoTimeout;
+constexpr int WriteConcernOptions::kNoWaiting;
-const StringData WriteConcernOptions::kWriteConcernField = "writeConcern"_sd;
+constexpr StringData WriteConcernOptions::kWriteConcernField;
const char WriteConcernOptions::kMajority[] = "majority";
// TODO (PM-1301): Remove once the stable Timestamp is allowed to advance past the oldest prepare
@@ -78,10 +78,10 @@ const BSONObj WriteConcernOptions::Unacknowledged(BSON("w" << W_NONE));
const BSONObj WriteConcernOptions::InternalMajorityNoSnapshot(
BSON("w" << WriteConcernOptions::kInternalMajorityNoSnapshot));
const BSONObj WriteConcernOptions::Majority(BSON("w" << WriteConcernOptions::kMajority));
-const Seconds WriteConcernOptions::kWriteConcernTimeoutSystem{15};
-const Seconds WriteConcernOptions::kWriteConcernTimeoutMigration{30};
-const Seconds WriteConcernOptions::kWriteConcernTimeoutSharding{60};
-const Seconds WriteConcernOptions::kWriteConcernTimeoutUserCommand{60};
+constexpr Seconds WriteConcernOptions::kWriteConcernTimeoutSystem;
+constexpr Seconds WriteConcernOptions::kWriteConcernTimeoutMigration;
+constexpr Seconds WriteConcernOptions::kWriteConcernTimeoutSharding;
+constexpr Seconds WriteConcernOptions::kWriteConcernTimeoutUserCommand;
WriteConcernOptions::WriteConcernOptions(int numNodes, SyncMode sync, int timeout)
diff --git a/src/mongo/db/write_concern_options.h b/src/mongo/db/write_concern_options.h
index 86b2e418ac6..615f614deaa 100644
--- a/src/mongo/db/write_concern_options.h
+++ b/src/mongo/db/write_concern_options.h
@@ -42,8 +42,8 @@ struct WriteConcernOptions {
public:
enum class SyncMode { UNSET, NONE, FSYNC, JOURNAL };
- static const int kNoTimeout;
- static const int kNoWaiting;
+ static constexpr int kNoTimeout = 0;
+ static constexpr int kNoWaiting = -1;
static const BSONObj Default;
static const BSONObj Acknowledged;
@@ -51,14 +51,14 @@ public:
static const BSONObj Majority;
static const BSONObj InternalMajorityNoSnapshot;
- static const StringData kWriteConcernField;
+ static constexpr StringData kWriteConcernField = "writeConcern"_sd;
static const char kMajority[]; // = "majority"
static const char kInternalMajorityNoSnapshot[]; // = "internalMajorityNoSnapshot"
- static const Seconds kWriteConcernTimeoutSystem;
- static const Seconds kWriteConcernTimeoutMigration;
- static const Seconds kWriteConcernTimeoutSharding;
- static const Seconds kWriteConcernTimeoutUserCommand;
+ static constexpr Seconds kWriteConcernTimeoutSystem{15};
+ static constexpr Seconds kWriteConcernTimeoutMigration{30};
+ static constexpr Seconds kWriteConcernTimeoutSharding{60};
+ static constexpr Seconds kWriteConcernTimeoutUserCommand{60};
WriteConcernOptions() {
reset();
diff --git a/src/mongo/s/catalog/sharding_catalog_client.cpp b/src/mongo/s/catalog/sharding_catalog_client.cpp
index 7014761a1b9..134a9ef34ae 100644
--- a/src/mongo/s/catalog/sharding_catalog_client.cpp
+++ b/src/mongo/s/catalog/sharding_catalog_client.cpp
@@ -30,9 +30,10 @@
#include "mongo/platform/basic.h"
-#include "mongo/db/write_concern_options.h"
#include "mongo/s/catalog/sharding_catalog_client.h"
+#include "mongo/db/write_concern_options.h"
+
namespace mongo {
const WriteConcernOptions ShardingCatalogClient::kMajorityWriteConcern(