summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2017-12-01 20:37:33 -0500
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2017-12-01 20:37:33 -0500
commit54db6356c47d7a639eae062818c3026561a64594 (patch)
treec11ead2d7bb621670387798b34f038efd047735e /src/mongo
parent19ced195b842d9521220f76b8dd7da8c929ad8ee (diff)
downloadmongo-54db6356c47d7a639eae062818c3026561a64594.tar.gz
Revert "SERVER-32070 migrate some easy stdx::bind to lambdas"
This reverts commit 7dc61c0f0c0160ad6cba831a0e12bef501ef3ad5.
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/bson/util/bson_extract_test.cpp2
-rw-r--r--src/mongo/client/fetcher.cpp4
-rw-r--r--src/mongo/client/fetcher_test.cpp16
-rw-r--r--src/mongo/client/remote_command_retry_scheduler.cpp4
-rw-r--r--src/mongo/db/auth/authz_manager_external_state_local.cpp2
-rw-r--r--src/mongo/db/catalog/database_impl.cpp15
-rw-r--r--src/mongo/db/catalog/index_catalog_impl.cpp7
-rw-r--r--src/mongo/db/ftdc/controller.cpp2
-rw-r--r--src/mongo/db/keys_collection_manager_sharding.cpp9
-rw-r--r--src/mongo/db/pipeline/expression.cpp62
-rw-r--r--src/mongo/db/repl/bgsync.cpp10
-rw-r--r--src/mongo/db/repl/check_quorum_for_config_change_test.cpp2
-rw-r--r--src/mongo/db/repl/collection_cloner_test.cpp104
-rw-r--r--src/mongo/db/repl/databases_cloner.cpp2
-rw-r--r--src/mongo/db/repl/multiapplier.cpp4
-rw-r--r--src/mongo/db/repl/repl_set_config.cpp13
-rw-r--r--src/mongo/db/repl/replication_coordinator_external_state_impl.cpp9
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_elect.cpp19
-rw-r--r--src/mongo/util/background.cpp3
-rw-r--r--src/mongo/util/concurrency/spin_lock_test.cpp2
-rw-r--r--src/mongo/util/concurrency/thread_pool.cpp2
21 files changed, 167 insertions, 126 deletions
diff --git a/src/mongo/bson/util/bson_extract_test.cpp b/src/mongo/bson/util/bson_extract_test.cpp
index 6778c01aa94..7681fbbf7a4 100644
--- a/src/mongo/bson/util/bson_extract_test.cpp
+++ b/src/mongo/bson/util/bson_extract_test.cpp
@@ -140,7 +140,7 @@ TEST(ExtractBSON, ExtractIntegerField) {
ASSERT_EQUALS(-(1LL << 55), v);
ASSERT_OK(bsonExtractIntegerField(BSON("a" << 5178), "a", &v));
ASSERT_EQUALS(5178, v);
- auto pred = [](long long x) { return x > 0; };
+ auto pred = stdx::bind(std::greater<long long>(), stdx::placeholders::_1, 0);
ASSERT_OK(bsonExtractIntegerFieldWithDefaultIf(BSON("a" << 1), "a", -1LL, pred, &v));
ASSERT_OK(bsonExtractIntegerFieldWithDefaultIf(BSON("a" << 1), "b", 1LL, pred, &v));
auto msg = "'a' has to be greater than zero";
diff --git a/src/mongo/client/fetcher.cpp b/src/mongo/client/fetcher.cpp
index 05ca4159810..7128c2800bd 100644
--- a/src/mongo/client/fetcher.cpp
+++ b/src/mongo/client/fetcher.cpp
@@ -186,7 +186,7 @@ Fetcher::Fetcher(executor::TaskExecutor* executor,
_firstRemoteCommandScheduler(
_executor,
RemoteCommandRequest(_source, _dbname, _cmdObj, _metadata, nullptr, _findNetworkTimeout),
- [this](const auto& x) { return _callback(x, kFirstBatchFieldName); },
+ stdx::bind(&Fetcher::_callback, this, stdx::placeholders::_1, kFirstBatchFieldName),
std::move(firstCommandRetryPolicy)) {
uassert(ErrorCodes::BadValue, "callback function cannot be null", work);
}
@@ -318,7 +318,7 @@ Status Fetcher::_scheduleGetMore(const BSONObj& cmdObj) {
_executor->scheduleRemoteCommand(
RemoteCommandRequest(
_source, _dbname, cmdObj, _metadata, nullptr, _getMoreNetworkTimeout),
- [this](const auto& x) { return _callback(x, kNextBatchFieldName); });
+ stdx::bind(&Fetcher::_callback, this, stdx::placeholders::_1, kNextBatchFieldName));
if (!scheduleResult.isOK()) {
return scheduleResult.getStatus();
diff --git a/src/mongo/client/fetcher_test.cpp b/src/mongo/client/fetcher_test.cpp
index 684d7de0532..1bc8b9008b6 100644
--- a/src/mongo/client/fetcher_test.cpp
+++ b/src/mongo/client/fetcher_test.cpp
@@ -101,7 +101,11 @@ FetcherTest::FetcherTest()
: status(getDetectableErrorStatus()), cursorId(-1), nextAction(Fetcher::NextAction::kInvalid) {}
Fetcher::CallbackFn FetcherTest::makeCallback() {
- return [this](const auto& x, const auto& y, const auto& z) { return _callback(x, y, z); };
+ return stdx::bind(&FetcherTest::_callback,
+ this,
+ stdx::placeholders::_1,
+ stdx::placeholders::_2,
+ stdx::placeholders::_3);
}
void FetcherTest::setUp() {
@@ -1008,9 +1012,13 @@ TEST_F(FetcherTest, ShutdownDuringSecondBatch) {
const BSONObj doc2 = BSON("_id" << 2);
bool isShutdownCalled = false;
- callbackHook = [this, doc2, &isShutdownCalled](const auto& x, const auto& y, const auto& z) {
- return shutdownDuringSecondBatch(x, y, z, doc2, &getExecutor(), &isShutdownCalled);
- };
+ callbackHook = stdx::bind(shutdownDuringSecondBatch,
+ stdx::placeholders::_1,
+ stdx::placeholders::_2,
+ stdx::placeholders::_3,
+ doc2,
+ &getExecutor(),
+ &isShutdownCalled);
processNetworkResponse(BSON("cursor" << BSON("id" << 1LL << "ns"
<< "db.coll"
diff --git a/src/mongo/client/remote_command_retry_scheduler.cpp b/src/mongo/client/remote_command_retry_scheduler.cpp
index 017f8ebf308..08e8d4477a8 100644
--- a/src/mongo/client/remote_command_retry_scheduler.cpp
+++ b/src/mongo/client/remote_command_retry_scheduler.cpp
@@ -223,7 +223,9 @@ std::string RemoteCommandRetryScheduler::toString() const {
Status RemoteCommandRetryScheduler::_schedule_inlock() {
++_currentAttempt;
auto scheduleResult = _executor->scheduleRemoteCommand(
- _request, [this](const auto& x) { return _remoteCommandCallback(x); });
+ _request,
+ stdx::bind(
+ &RemoteCommandRetryScheduler::_remoteCommandCallback, this, stdx::placeholders::_1));
if (!scheduleResult.isOK()) {
return scheduleResult.getStatus();
diff --git a/src/mongo/db/auth/authz_manager_external_state_local.cpp b/src/mongo/db/auth/authz_manager_external_state_local.cpp
index 3c340c5cada..ad8b34fbce5 100644
--- a/src/mongo/db/auth/authz_manager_external_state_local.cpp
+++ b/src/mongo/db/auth/authz_manager_external_state_local.cpp
@@ -493,7 +493,7 @@ Status AuthzManagerExternalStateLocal::_initializeRoleGraph(OperationContext* op
AuthorizationManager::rolesCollectionNamespace,
BSONObj(),
BSONObj(),
- [p = &newRoleGraph](const auto& x) { return addRoleFromDocumentOrWarn(p, x); });
+ stdx::bind(addRoleFromDocumentOrWarn, &newRoleGraph, stdx::placeholders::_1));
if (!status.isOK())
return status;
diff --git a/src/mongo/db/catalog/database_impl.cpp b/src/mongo/db/catalog/database_impl.cpp
index fdbbc1db591..dc044477718 100644
--- a/src/mongo/db/catalog/database_impl.cpp
+++ b/src/mongo/db/catalog/database_impl.cpp
@@ -1079,17 +1079,20 @@ auto mongo::userCreateNSImpl(OperationContext* opCtx,
}
status =
- validateStorageOptions(collectionOptions.storageEngine, [](const auto& x, const auto& y) {
- return x->validateCollectionStorageOptions(y);
- });
+ validateStorageOptions(collectionOptions.storageEngine,
+ stdx::bind(&StorageEngine::Factory::validateCollectionStorageOptions,
+ stdx::placeholders::_1,
+ stdx::placeholders::_2));
if (!status.isOK())
return status;
if (auto indexOptions = collectionOptions.indexOptionDefaults["storageEngine"]) {
- status = validateStorageOptions(indexOptions.Obj(), [](const auto& x, const auto& y) {
- return x->validateIndexStorageOptions(y);
- });
+ status =
+ validateStorageOptions(indexOptions.Obj(),
+ stdx::bind(&StorageEngine::Factory::validateIndexStorageOptions,
+ stdx::placeholders::_1,
+ stdx::placeholders::_2));
if (!status.isOK()) {
return status;
diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp
index b92c23b02f5..071a134963a 100644
--- a/src/mongo/db/catalog/index_catalog_impl.cpp
+++ b/src/mongo/db/catalog/index_catalog_impl.cpp
@@ -734,9 +734,10 @@ Status IndexCatalogImpl::_isSpecOk(OperationContext* opCtx, const BSONObj& spec)
"Please remove the field or include valid options.");
}
Status storageEngineStatus =
- validateStorageOptions(storageEngineOptions, [](const auto& x, const auto& y) {
- return x->validateIndexStorageOptions(y);
- });
+ validateStorageOptions(storageEngineOptions,
+ stdx::bind(&StorageEngine::Factory::validateIndexStorageOptions,
+ stdx::placeholders::_1,
+ stdx::placeholders::_2));
if (!storageEngineStatus.isOK()) {
return storageEngineStatus;
}
diff --git a/src/mongo/db/ftdc/controller.cpp b/src/mongo/db/ftdc/controller.cpp
index c8748cc8b02..bc3d4df444c 100644
--- a/src/mongo/db/ftdc/controller.cpp
+++ b/src/mongo/db/ftdc/controller.cpp
@@ -139,7 +139,7 @@ void FTDCController::start() {
<< _path.generic_string() << "'";
// Start the thread
- _thread = stdx::thread([this] { doLoop(); });
+ _thread = stdx::thread(stdx::bind(&FTDCController::doLoop, this));
{
stdx::lock_guard<stdx::mutex> lock(_mutex);
diff --git a/src/mongo/db/keys_collection_manager_sharding.cpp b/src/mongo/db/keys_collection_manager_sharding.cpp
index 8baf74d073c..b60db4dc112 100644
--- a/src/mongo/db/keys_collection_manager_sharding.cpp
+++ b/src/mongo/db/keys_collection_manager_sharding.cpp
@@ -323,9 +323,12 @@ void KeysCollectionManagerSharding::PeriodicRunner::start(ServiceContext* servic
invariant(!_backgroundThread.joinable());
invariant(!_inShutdown);
- _backgroundThread = stdx::thread([this, service, threadName, refreshInterval] {
- _doPeriodicRefresh(service, threadName, refreshInterval);
- });
+ _backgroundThread =
+ stdx::thread(stdx::bind(&KeysCollectionManagerSharding::PeriodicRunner::_doPeriodicRefresh,
+ this,
+ service,
+ threadName,
+ refreshInterval));
}
void KeysCollectionManagerSharding::PeriodicRunner::stop() {
diff --git a/src/mongo/db/pipeline/expression.cpp b/src/mongo/db/pipeline/expression.cpp
index 3c3156b3435..28f57d7061b 100644
--- a/src/mongo/db/pipeline/expression.cpp
+++ b/src/mongo/db/pipeline/expression.cpp
@@ -705,26 +705,48 @@ Value ExpressionCoerceToBool::serialize(bool explain) const {
/* ----------------------- ExpressionCompare --------------------------- */
-namespace {
-struct BoundOp {
- ExpressionCompare::CmpOp op;
-
- auto operator()(const boost::intrusive_ptr<ExpressionContext>& expCtx,
- BSONElement bsonExpr,
- const VariablesParseState& vps) const {
- return ExpressionCompare::parse(expCtx, std::move(bsonExpr), vps, op);
- }
-};
-} // namespace
-
-REGISTER_EXPRESSION(cmp, BoundOp{ExpressionCompare::CMP});
-REGISTER_EXPRESSION(eq, BoundOp{ExpressionCompare::EQ});
-REGISTER_EXPRESSION(gt, BoundOp{ExpressionCompare::GT});
-REGISTER_EXPRESSION(gte, BoundOp{ExpressionCompare::GTE});
-REGISTER_EXPRESSION(lt, BoundOp{ExpressionCompare::LT});
-REGISTER_EXPRESSION(lte, BoundOp{ExpressionCompare::LTE});
-REGISTER_EXPRESSION(ne, BoundOp{ExpressionCompare::NE});
-
+REGISTER_EXPRESSION(cmp,
+ stdx::bind(ExpressionCompare::parse,
+ stdx::placeholders::_1,
+ stdx::placeholders::_2,
+ stdx::placeholders::_3,
+ ExpressionCompare::CMP));
+REGISTER_EXPRESSION(eq,
+ stdx::bind(ExpressionCompare::parse,
+ stdx::placeholders::_1,
+ stdx::placeholders::_2,
+ stdx::placeholders::_3,
+ ExpressionCompare::EQ));
+REGISTER_EXPRESSION(gt,
+ stdx::bind(ExpressionCompare::parse,
+ stdx::placeholders::_1,
+ stdx::placeholders::_2,
+ stdx::placeholders::_3,
+ ExpressionCompare::GT));
+REGISTER_EXPRESSION(gte,
+ stdx::bind(ExpressionCompare::parse,
+ stdx::placeholders::_1,
+ stdx::placeholders::_2,
+ stdx::placeholders::_3,
+ ExpressionCompare::GTE));
+REGISTER_EXPRESSION(lt,
+ stdx::bind(ExpressionCompare::parse,
+ stdx::placeholders::_1,
+ stdx::placeholders::_2,
+ stdx::placeholders::_3,
+ ExpressionCompare::LT));
+REGISTER_EXPRESSION(lte,
+ stdx::bind(ExpressionCompare::parse,
+ stdx::placeholders::_1,
+ stdx::placeholders::_2,
+ stdx::placeholders::_3,
+ ExpressionCompare::LTE));
+REGISTER_EXPRESSION(ne,
+ stdx::bind(ExpressionCompare::parse,
+ stdx::placeholders::_1,
+ stdx::placeholders::_2,
+ stdx::placeholders::_3,
+ ExpressionCompare::NE));
intrusive_ptr<Expression> ExpressionCompare::parse(
const boost::intrusive_ptr<ExpressionContext>& expCtx,
BSONElement bsonExpr,
diff --git a/src/mongo/db/repl/bgsync.cpp b/src/mongo/db/repl/bgsync.cpp
index 1a8246d9136..24024b8a4af 100644
--- a/src/mongo/db/repl/bgsync.cpp
+++ b/src/mongo/db/repl/bgsync.cpp
@@ -155,7 +155,7 @@ void BackgroundSync::startup(OperationContext* opCtx) {
_oplogBuffer->startup(opCtx);
invariant(!_producerThread);
- _producerThread.reset(new stdx::thread([this] { _run(); }));
+ _producerThread.reset(new stdx::thread(stdx::bind(&BackgroundSync::_run, this)));
}
void BackgroundSync::shutdown(OperationContext* opCtx) {
@@ -444,9 +444,11 @@ void BackgroundSync::_produce() {
syncSourceResp.rbid,
true /* requireFresherSyncSource */,
&dataReplicatorExternalState,
- [this](const auto& a1, const auto& a2, const auto& a3) {
- return _enqueueDocuments(a1, a2, a3);
- },
+ stdx::bind(&BackgroundSync::_enqueueDocuments,
+ this,
+ stdx::placeholders::_1,
+ stdx::placeholders::_2,
+ stdx::placeholders::_3),
onOplogFetcherShutdownCallbackFn,
bgSyncOplogFetcherBatchSize);
stdx::lock_guard<stdx::mutex> lock(_mutex);
diff --git a/src/mongo/db/repl/check_quorum_for_config_change_test.cpp b/src/mongo/db/repl/check_quorum_for_config_change_test.cpp
index a81c5cd9d8c..696e66764e3 100644
--- a/src/mongo/db/repl/check_quorum_for_config_change_test.cpp
+++ b/src/mongo/db/repl/check_quorum_for_config_change_test.cpp
@@ -97,7 +97,7 @@ void CheckQuorumTest::startQuorumCheck(const ReplSetConfig& config, int myIndex)
ASSERT_FALSE(_quorumCheckThread);
_isQuorumCheckDone = false;
_quorumCheckThread.reset(
- new stdx::thread([this, config, myIndex] { _runQuorumCheck(config, myIndex); }));
+ new stdx::thread(stdx::bind(&CheckQuorumTest::_runQuorumCheck, this, config, myIndex)));
}
Status CheckQuorumTest::waitForQuorumCheck() {
diff --git a/src/mongo/db/repl/collection_cloner_test.cpp b/src/mongo/db/repl/collection_cloner_test.cpp
index c3f2bd92cef..dfe09f3ee2f 100644
--- a/src/mongo/db/repl/collection_cloner_test.cpp
+++ b/src/mongo/db/repl/collection_cloner_test.cpp
@@ -63,13 +63,8 @@ public:
BaseCloner* getCloner() const override;
protected:
- auto setStatusCallback() {
- return [this](const Status& s) { setStatus(s); };
- }
-
void setUp() override;
void tearDown() override;
-
std::vector<BSONObj> makeSecondaryIndexSpecs(const NamespaceString& nss);
// A simple arbitrary value to use as the default batch size.
@@ -89,15 +84,16 @@ void CollectionClonerTest::setUp() {
BaseClonerTest::setUp();
options = {};
collectionCloner.reset(nullptr);
- collectionCloner = stdx::make_unique<CollectionCloner>(&getExecutor(),
- dbWorkThreadPool.get(),
- target,
- nss,
- options,
- setStatusCallback(),
- storageInterface.get(),
- defaultBatchSize,
- defaultNumCloningCursors);
+ collectionCloner = stdx::make_unique<CollectionCloner>(
+ &getExecutor(),
+ dbWorkThreadPool.get(),
+ target,
+ nss,
+ options,
+ stdx::bind(&CollectionClonerTest::setStatus, this, stdx::placeholders::_1),
+ storageInterface.get(),
+ defaultBatchSize,
+ defaultNumCloningCursors);
collectionStats = CollectionMockStats();
storageInterface->createCollectionForBulkFn =
[this](const NamespaceString& nss,
@@ -366,15 +362,16 @@ TEST_F(CollectionClonerTest,
return str::equals("listIndexes", request.cmdObj.firstElementFieldName());
});
- collectionCloner = stdx::make_unique<CollectionCloner>(&_executorProxy,
- dbWorkThreadPool.get(),
- target,
- nss,
- options,
- setStatusCallback(),
- storageInterface.get(),
- defaultBatchSize,
- defaultNumCloningCursors);
+ collectionCloner = stdx::make_unique<CollectionCloner>(
+ &_executorProxy,
+ dbWorkThreadPool.get(),
+ target,
+ nss,
+ options,
+ stdx::bind(&CollectionClonerTest::setStatus, this, stdx::placeholders::_1),
+ storageInterface.get(),
+ defaultBatchSize,
+ defaultNumCloningCursors);
ASSERT_OK(collectionCloner->startup());
@@ -389,15 +386,16 @@ TEST_F(CollectionClonerTest,
TEST_F(CollectionClonerTest, DoNotCreateIDIndexIfAutoIndexIdUsed) {
options = {};
options.autoIndexId = CollectionOptions::NO;
- collectionCloner.reset(new CollectionCloner(&getExecutor(),
- dbWorkThreadPool.get(),
- target,
- nss,
- options,
- setStatusCallback(),
- storageInterface.get(),
- defaultBatchSize,
- defaultNumCloningCursors));
+ collectionCloner.reset(new CollectionCloner(
+ &getExecutor(),
+ dbWorkThreadPool.get(),
+ target,
+ nss,
+ options,
+ stdx::bind(&CollectionClonerTest::setStatus, this, stdx::placeholders::_1),
+ storageInterface.get(),
+ defaultBatchSize,
+ defaultNumCloningCursors));
NamespaceString collNss;
CollectionOptions collOptions;
@@ -1411,15 +1409,16 @@ protected:
void startupWithUUID(int maxNumCloningCursors = 1) {
collectionCloner.reset();
options.uuid = UUID::gen();
- collectionCloner = stdx::make_unique<CollectionCloner>(&getExecutor(),
- dbWorkThreadPool.get(),
- target,
- alternateNss,
- options,
- setStatusCallback(),
- storageInterface.get(),
- defaultBatchSize,
- maxNumCloningCursors);
+ collectionCloner = stdx::make_unique<CollectionCloner>(
+ &getExecutor(),
+ dbWorkThreadPool.get(),
+ target,
+ alternateNss,
+ options,
+ stdx::bind(&CollectionClonerTest::setStatus, this, stdx::placeholders::_1),
+ storageInterface.get(),
+ defaultBatchSize,
+ maxNumCloningCursors);
ASSERT_OK(collectionCloner->startup());
}
@@ -1576,10 +1575,6 @@ protected:
void tearDown() override;
std::vector<BSONObj> generateDocs(std::size_t numDocs);
- auto setStatusCallback() {
- return [this](const Status& s) { setStatus(s); };
- }
-
// A simple arbitrary value to use as the default batch size.
const int defaultBatchSize = 1024;
@@ -1597,15 +1592,16 @@ void ParallelCollectionClonerTest::setUp() {
BaseClonerTest::setUp();
options = {};
collectionCloner.reset(nullptr);
- collectionCloner = stdx::make_unique<CollectionCloner>(&getExecutor(),
- dbWorkThreadPool.get(),
- target,
- nss,
- options,
- setStatusCallback(),
- storageInterface.get(),
- defaultBatchSize,
- defaultNumCloningCursors);
+ collectionCloner = stdx::make_unique<CollectionCloner>(
+ &getExecutor(),
+ dbWorkThreadPool.get(),
+ target,
+ nss,
+ options,
+ stdx::bind(&CollectionClonerTest::setStatus, this, stdx::placeholders::_1),
+ storageInterface.get(),
+ defaultBatchSize,
+ defaultNumCloningCursors);
collectionStats = CollectionMockStats();
storageInterface->createCollectionForBulkFn =
[this](const NamespaceString& nss,
diff --git a/src/mongo/db/repl/databases_cloner.cpp b/src/mongo/db/repl/databases_cloner.cpp
index 3aac650d501..886ccf753c3 100644
--- a/src/mongo/db/repl/databases_cloner.cpp
+++ b/src/mongo/db/repl/databases_cloner.cpp
@@ -210,7 +210,7 @@ Status DatabasesCloner::startup() noexcept {
_listDBsScheduler = stdx::make_unique<RemoteCommandRetryScheduler>(
_exec,
listDBsReq,
- [this](const auto& x) { _onListDatabaseFinish(x); },
+ stdx::bind(&DatabasesCloner::_onListDatabaseFinish, this, stdx::placeholders::_1),
RemoteCommandRetryScheduler::makeRetryPolicy(
numInitialSyncListDatabasesAttempts.load(),
executor::RemoteCommandRequest::kNoTimeout,
diff --git a/src/mongo/db/repl/multiapplier.cpp b/src/mongo/db/repl/multiapplier.cpp
index e748710ef6e..32efe2c68a7 100644
--- a/src/mongo/db/repl/multiapplier.cpp
+++ b/src/mongo/db/repl/multiapplier.cpp
@@ -91,8 +91,8 @@ Status MultiApplier::startup() noexcept {
return Status(ErrorCodes::ShutdownInProgress, "multi applier completed");
}
- auto scheduleResult = _executor->scheduleWork(
- [=](const executor::TaskExecutor::CallbackArgs& cbd) { return _callback(cbd); });
+ auto scheduleResult =
+ _executor->scheduleWork(stdx::bind(&MultiApplier::_callback, this, stdx::placeholders::_1));
if (!scheduleResult.isOK()) {
_state = State::kComplete;
return scheduleResult.getStatus();
diff --git a/src/mongo/db/repl/repl_set_config.cpp b/src/mongo/db/repl/repl_set_config.cpp
index 03619b1a859..910e7c386d4 100644
--- a/src/mongo/db/repl/repl_set_config.cpp
+++ b/src/mongo/db/repl/repl_set_config.cpp
@@ -242,8 +242,8 @@ Status ReplSetConfig::_parseSettingsSubdocument(const BSONObj& settings) {
//
// Parse electionTimeoutMillis
//
+ auto greaterThanZero = stdx::bind(std::greater<long long>(), stdx::placeholders::_1, 0);
long long electionTimeoutMillis;
- auto greaterThanZero = [](const auto& x) { return x > 0; };
auto electionTimeoutStatus = bsonExtractIntegerFieldWithDefaultIf(
settings,
kElectionTimeoutFieldName,
@@ -706,10 +706,13 @@ StatusWith<ReplSetTagPattern> ReplSetConfig::findCustomWriteMode(StringData patt
}
void ReplSetConfig::_calculateMajorities() {
- const int voters =
- std::count_if(begin(_members), end(_members), [](const auto& x) { return x.isVoter(); });
- const int arbiters = std::count_if(
- begin(_members), end(_members), [](const auto& x) { return x.isArbiter(); });
+ const int voters = std::count_if(_members.begin(),
+ _members.end(),
+ stdx::bind(&MemberConfig::isVoter, stdx::placeholders::_1));
+ const int arbiters =
+ std::count_if(_members.begin(),
+ _members.end(),
+ stdx::bind(&MemberConfig::isArbiter, stdx::placeholders::_1));
_totalVotingMembers = voters;
_majorityVoteCount = voters / 2 + 1;
_writeMajority = std::min(_majorityVoteCount, voters - arbiters);
diff --git a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
index cd822f9fb0c..c26edc2f70f 100644
--- a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
@@ -242,10 +242,11 @@ void ReplicationCoordinatorExternalStateImpl::startSteadyStateReplication(
_applierThread->startup();
log() << "Starting replication reporter thread";
invariant(!_syncSourceFeedbackThread);
- _syncSourceFeedbackThread = stdx::make_unique<stdx::thread>(
- [this, replCoord] {
- _syncSourceFeedback.run(_taskExecutor.get(), _bgSync.get(), replCoord);
- });
+ _syncSourceFeedbackThread.reset(new stdx::thread(stdx::bind(&SyncSourceFeedback::run,
+ &_syncSourceFeedback,
+ _taskExecutor.get(),
+ _bgSync.get(),
+ replCoord)));
}
void ReplicationCoordinatorExternalStateImpl::stopDataReplication(OperationContext* opCtx) {
diff --git a/src/mongo/db/repl/replication_coordinator_impl_elect.cpp b/src/mongo/db/repl/replication_coordinator_impl_elect.cpp
index b50252225a0..ac6e07ce3ee 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_elect.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_elect.cpp
@@ -144,9 +144,7 @@ void ReplicationCoordinatorImpl::_startElectSelf_inlock() {
fassert(18681, nextPhaseEvh.getStatus());
_replExecutor
->onEvent(nextPhaseEvh.getValue(),
- [this](const mongo::executor::TaskExecutor::CallbackArgs&) {
- _onFreshnessCheckComplete();
- })
+ stdx::bind(&ReplicationCoordinatorImpl::_onFreshnessCheckComplete, this))
.status_with_transitional_ignore();
lossGuard.dismiss();
}
@@ -182,9 +180,9 @@ void ReplicationCoordinatorImpl::_onFreshnessCheckComplete() {
<< dateToISOStringLocal(nextCandidateTime);
_topCoord->setElectionSleepUntil(nextCandidateTime);
_scheduleWorkAt(nextCandidateTime,
- [=](const executor::TaskExecutor::CallbackArgs& cbData) {
- _recoverFromElectionTie(cbData);
- });
+ stdx::bind(&ReplicationCoordinatorImpl::_recoverFromElectionTie,
+ this,
+ stdx::placeholders::_1));
_sleptLastElection = true;
return;
}
@@ -222,7 +220,7 @@ void ReplicationCoordinatorImpl::_onFreshnessCheckComplete() {
_replExecutor
->onEvent(nextPhaseEvh.getValue(),
- [=](const executor::TaskExecutor::CallbackArgs&) { _onElectCmdRunnerComplete(); })
+ stdx::bind(&ReplicationCoordinatorImpl::_onElectCmdRunnerComplete, this))
.status_with_transitional_ignore();
lossGuard.dismiss();
}
@@ -254,9 +252,10 @@ void ReplicationCoordinatorImpl::_onElectCmdRunnerComplete() {
const Date_t nextCandidateTime = now + ms;
log() << "waiting until " << nextCandidateTime << " before standing for election again";
_topCoord->setElectionSleepUntil(nextCandidateTime);
- _scheduleWorkAt(nextCandidateTime, [=](const executor::TaskExecutor::CallbackArgs& cbData) {
- _recoverFromElectionTie(cbData);
- });
+ _scheduleWorkAt(nextCandidateTime,
+ stdx::bind(&ReplicationCoordinatorImpl::_recoverFromElectionTie,
+ this,
+ stdx::placeholders::_1));
return;
}
diff --git a/src/mongo/util/background.cpp b/src/mongo/util/background.cpp
index 155ad760413..7c0575daa46 100644
--- a/src/mongo/util/background.cpp
+++ b/src/mongo/util/background.cpp
@@ -177,7 +177,8 @@ void BackgroundJob::go() {
// If the job is already 'done', for instance because it was cancelled or already
// finished, ignore additional requests to run the job.
if (_status->state == NotStarted) {
- stdx::thread{[this] { jobBody(); }}.detach();
+ stdx::thread t(stdx::bind(&BackgroundJob::jobBody, this));
+ t.detach();
_status->state = Running;
}
}
diff --git a/src/mongo/util/concurrency/spin_lock_test.cpp b/src/mongo/util/concurrency/spin_lock_test.cpp
index 6d41251a2a9..a830ba07db6 100644
--- a/src/mongo/util/concurrency/spin_lock_test.cpp
+++ b/src/mongo/util/concurrency/spin_lock_test.cpp
@@ -50,7 +50,7 @@ public:
}
void start(int increments) {
- _t = new stdx::thread([this, increments] { test(increments); });
+ _t = new stdx::thread(mongo::stdx::bind(&LockTester::test, this, increments));
}
void join() {
diff --git a/src/mongo/util/concurrency/thread_pool.cpp b/src/mongo/util/concurrency/thread_pool.cpp
index 411e19ebd30..06cff9f3b4d 100644
--- a/src/mongo/util/concurrency/thread_pool.cpp
+++ b/src/mongo/util/concurrency/thread_pool.cpp
@@ -382,7 +382,7 @@ void ThreadPool::_startWorkerThread_inlock() {
invariant(_threads.size() < _options.maxThreads);
const std::string threadName = str::stream() << _options.threadNamePrefix << _nextThreadId++;
try {
- _threads.emplace_back([this, threadName] { _workerThreadBody(this, threadName); });
+ _threads.emplace_back(stdx::bind(&ThreadPool::_workerThreadBody, this, threadName));
++_numIdleThreads;
} catch (const std::exception& ex) {
error() << "Failed to start " << threadName << "; " << _threads.size()