diff options
author | Adam Midvidy <amidvidy@gmail.com> | 2015-06-17 14:29:48 -0400 |
---|---|---|
committer | Adam Midvidy <amidvidy@gmail.com> | 2015-06-18 13:09:18 -0400 |
commit | 149d8c8f83017db23b104da1f020d0a994fb79f9 (patch) | |
tree | b3de559193c25708fca27234f8d498f08d444ac9 /src | |
parent | dd759f777875702f9618ed9379c5379247cdb7d1 (diff) | |
download | mongo-149d8c8f83017db23b104da1f020d0a994fb79f9.tar.gz |
SERVER-18723 boost -> stdx for thread
Diffstat (limited to 'src')
74 files changed, 282 insertions, 304 deletions
diff --git a/src/mongo/client/examples/mongoperf.cpp b/src/mongo/client/examples/mongoperf.cpp index b9f12f1ad20..f74ec14acad 100644 --- a/src/mongo/client/examples/mongoperf.cpp +++ b/src/mongo/client/examples/mongoperf.cpp @@ -42,19 +42,18 @@ #include <iostream> #include <boost/filesystem/operations.hpp> -#include <boost/thread/thread.hpp> #include "mongo/db/jsobj.h" #include "mongo/db/json.h" -#include "mongo/db/storage/mmap_v1/mmap.h" #include "mongo/db/storage/mmap_v1/logfile.h" +#include "mongo/db/storage/mmap_v1/mmap.h" #include "mongo/platform/atomic_word.h" +#include "mongo/stdx/thread.h" #include "mongo/util/allocator.h" #include "mongo/util/mongoutils/str.h" +#include "mongo/util/processinfo.h" #include "mongo/util/time_support.h" #include "mongo/util/timer.h" -#include "mongo/util/processinfo.h" - using namespace std; using namespace mongo; @@ -211,7 +210,7 @@ void go() { syncDelaySecs = options["syncDelay"].numberInt(); if( syncDelaySecs ) { - boost::thread t(syncThread); + stdx::thread t(syncThread); } } @@ -236,7 +235,7 @@ void go() { if( nthr < wthr ) { while( nthr < wthr && nthr < d ) { nthr++; - boost::thread w(workerThread); + stdx::thread w(workerThread); } cout << "new thread, total running : " << nthr << endl; d *= 2; diff --git a/src/mongo/client/replica_set_monitor.cpp b/src/mongo/client/replica_set_monitor.cpp index f8576782fcd..bfadcc339c3 100644 --- a/src/mongo/client/replica_set_monitor.cpp +++ b/src/mongo/client/replica_set_monitor.cpp @@ -32,7 +32,6 @@ #include "mongo/client/replica_set_monitor.h" #include <algorithm> -#include <boost/thread.hpp> #include <boost/thread/condition.hpp> #include <limits> @@ -40,6 +39,7 @@ #include "mongo/client/connpool.h" #include "mongo/client/global_conn_pool.h" #include "mongo/client/replica_set_monitor_internal.h" +#include "mongo/stdx/thread.h" #include "mongo/util/background.h" #include "mongo/util/concurrency/mutex.h" // for StaticObserver #include "mongo/util/debug_util.h" @@ -640,7 +640,7 @@ namespace { if (configChangeHook) { // call from a separate thread to avoid blocking and holding lock while potentially // going over the network - boost::thread bg(configChangeHook, _set->name, _set->getServerAddress()); + stdx::thread bg(configChangeHook, _set->name, _set->getServerAddress()); bg.detach(); } } diff --git a/src/mongo/db/background.cpp b/src/mongo/db/background.cpp index ffa053bc7e6..2d492a103b4 100644 --- a/src/mongo/db/background.cpp +++ b/src/mongo/db/background.cpp @@ -32,11 +32,11 @@ #include "mongo/db/background.h" -#include <boost/thread.hpp> #include <iostream> #include <string> #include "mongo/base/disallow_copying.h" +#include "mongo/stdx/thread.h" #include "mongo/util/assert_util.h" #include "mongo/util/map_util.h" #include "mongo/util/mongoutils/str.h" diff --git a/src/mongo/db/client.h b/src/mongo/db/client.h index 1368506b9ea..4f27c639b0a 100644 --- a/src/mongo/db/client.h +++ b/src/mongo/db/client.h @@ -36,13 +36,12 @@ #pragma once -#include <boost/thread/thread.hpp> - #include "mongo/db/client_basic.h" #include "mongo/db/namespace_string.h" #include "mongo/db/operation_context.h" #include "mongo/db/service_context.h" #include "mongo/platform/unordered_set.h" +#include "mongo/stdx/thread.h" #include "mongo/util/concurrency/spin_lock.h" #include "mongo/util/concurrency/threadlocal.h" @@ -133,7 +132,7 @@ namespace mongo { const std::string _desc; // OS id of the thread, which owns this client - const boost::thread::id _threadId; + const stdx::thread::id _threadId; // > 0 for things "conn", 0 otherwise const ConnectionId _connectionId; diff --git a/src/mongo/db/curop_test.cpp b/src/mongo/db/curop_test.cpp index 1f4f58153eb..0edbde43d31 100644 --- a/src/mongo/db/curop_test.cpp +++ b/src/mongo/db/curop_test.cpp @@ -28,8 +28,6 @@ #include "mongo/platform/basic.h" -#include <boost/thread/thread.hpp> - #include "mongo/base/init.h" #include "mongo/db/client.h" #include "mongo/db/curop.h" @@ -37,6 +35,7 @@ #include "mongo/db/service_context.h" #include "mongo/db/service_context_noop.h" #include "mongo/stdx/memory.h" +#include "mongo/stdx/thread.h" #include "mongo/unittest/unittest.h" namespace mongo { @@ -65,7 +64,7 @@ namespace mongo { } MONGO_INITIALIZER(CurOpTest)(InitializerContext* context) { - boost::thread t(timeTrackerSetup); + stdx::thread t(timeTrackerSetup); // Wait for listener thread to start tracking time. while (Listener::getElapsedTimeMillis() == 0) { diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp index b1f33c66204..4969640bea7 100644 --- a/src/mongo/db/db.cpp +++ b/src/mongo/db/db.cpp @@ -32,7 +32,6 @@ #include "mongo/platform/basic.h" -#include <boost/thread/thread.hpp> #include <boost/filesystem/operations.hpp> #include <boost/optional.hpp> #include <fstream> @@ -61,8 +60,6 @@ #include "mongo/db/dbdirectclient.h" #include "mongo/db/dbmessage.h" #include "mongo/db/dbwebserver.h" -#include "mongo/db/service_context_d.h" -#include "mongo/db/service_context.h" #include "mongo/db/index_names.h" #include "mongo/db/index_rebuilder.h" #include "mongo/db/initialize_server_global_state.h" @@ -85,6 +82,8 @@ #include "mongo/db/repl/topology_coordinator_impl.h" #include "mongo/db/restapi.h" #include "mongo/db/server_parameters.h" +#include "mongo/db/service_context.h" +#include "mongo/db/service_context_d.h" #include "mongo/db/startup_warnings_mongod.h" #include "mongo/db/stats/counters.h" #include "mongo/db/stats/snapshots.h" @@ -96,6 +95,7 @@ #include "mongo/platform/process_id.h" #include "mongo/scripting/engine.h" #include "mongo/stdx/memory.h" +#include "mongo/stdx/thread.h" #include "mongo/util/assert_util.h" #include "mongo/util/cmdline_utils/censor_cmdline.h" #include "mongo/util/concurrency/task.h" @@ -530,7 +530,7 @@ namespace mongo { snapshotThread.go(); invariant(dbWebServer); - boost::thread web(stdx::bind(&webServerListenThread, dbWebServer)); + stdx::thread web(stdx::bind(&webServerListenThread, dbWebServer)); web.detach(); } diff --git a/src/mongo/db/global_timestamp.cpp b/src/mongo/db/global_timestamp.cpp index 3e18ad3e2aa..6fd17da2d28 100644 --- a/src/mongo/db/global_timestamp.cpp +++ b/src/mongo/db/global_timestamp.cpp @@ -28,9 +28,8 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kDefault -#include <boost/thread.hpp> - #include "mongo/db/global_timestamp.h" +#include "mongo/stdx/thread.h" #include "mongo/util/concurrency/mutex.h" #include "mongo/util/log.h" diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp index 6bbacc43242..f999084fdd7 100644 --- a/src/mongo/db/instance.cpp +++ b/src/mongo/db/instance.cpp @@ -32,7 +32,6 @@ #include "mongo/platform/basic.h" -#include <boost/thread/thread.hpp> #include <fstream> #include <memory> @@ -59,7 +58,6 @@ #include "mongo/db/dbmessage.h" #include "mongo/db/exec/delete.h" #include "mongo/db/exec/update.h" -#include "mongo/db/service_context.h" #include "mongo/db/global_timestamp.h" #include "mongo/db/instance.h" #include "mongo/db/introspect.h" @@ -81,6 +79,7 @@ #include "mongo/db/query/get_executor.h" #include "mongo/db/repl/oplog.h" #include "mongo/db/repl/replication_coordinator_global.h" +#include "mongo/db/service_context.h" #include "mongo/db/stats/counters.h" #include "mongo/db/storage/storage_engine.h" #include "mongo/db/storage_options.h" @@ -92,14 +91,15 @@ #include "mongo/rpc/legacy_reply_builder.h" #include "mongo/rpc/legacy_request.h" #include "mongo/rpc/legacy_request_builder.h" -#include "mongo/rpc/request_interface.h" #include "mongo/rpc/metadata.h" +#include "mongo/rpc/request_interface.h" #include "mongo/s/catalog/catalog_manager.h" #include "mongo/s/d_state.h" #include "mongo/s/grid.h" #include "mongo/s/stale_exception.h" // for SendStaleConfigException #include "mongo/scripting/engine.h" #include "mongo/stdx/memory.h" +#include "mongo/stdx/thread.h" #include "mongo/util/exit.h" #include "mongo/util/fail_point_service.h" #include "mongo/util/log.h" @@ -1253,7 +1253,7 @@ namespace { /* must do this before unmapping mem or you may get a seg fault */ log(LogComponent::kNetwork) << "shutdown: going to close sockets..." << endl; - boost::thread close_socket_thread( stdx::bind(MessagingPort::closeAllSockets, 0) ); + stdx::thread close_socket_thread( stdx::bind(MessagingPort::closeAllSockets, 0) ); getGlobalServiceContext()->shutdownGlobalStorageEngineCleanly(); } diff --git a/src/mongo/db/range_deleter.cpp b/src/mongo/db/range_deleter.cpp index 55e32533aaa..771aa9074f7 100644 --- a/src/mongo/db/range_deleter.cpp +++ b/src/mongo/db/range_deleter.cpp @@ -193,7 +193,7 @@ namespace mongo { void RangeDeleter::startWorkers() { if (!_worker) { - _worker.reset(new boost::thread(stdx::bind(&RangeDeleter::doWork, this))); + _worker.reset(new stdx::thread(stdx::bind(&RangeDeleter::doWork, this))); } } diff --git a/src/mongo/db/range_deleter.h b/src/mongo/db/range_deleter.h index 2a6b5ccb7af..4d9db11dd74 100644 --- a/src/mongo/db/range_deleter.h +++ b/src/mongo/db/range_deleter.h @@ -28,7 +28,6 @@ #pragma once -#include <boost/thread/thread.hpp> #include <deque> #include <set> #include <string> @@ -40,6 +39,7 @@ #include "mongo/db/jsobj.h" #include "mongo/db/operation_context.h" #include "mongo/db/write_concern_options.h" +#include "mongo/stdx/thread.h" #include "mongo/util/concurrency/mutex.h" #include "mongo/util/concurrency/synchronization.h" #include "mongo/util/time_support.h" @@ -200,7 +200,7 @@ namespace mongo { std::unique_ptr<RangeDeleterEnv> _env; // Initially not active. Must be started explicitly. - std::unique_ptr<boost::thread> _worker; + std::unique_ptr<stdx::thread> _worker; // Protects _stopRequested. mutable mutex _stopMutex; diff --git a/src/mongo/db/range_deleter_test.cpp b/src/mongo/db/range_deleter_test.cpp index b85c0ac8476..9ec9e1fc1c3 100644 --- a/src/mongo/db/range_deleter_test.cpp +++ b/src/mongo/db/range_deleter_test.cpp @@ -26,7 +26,6 @@ * it in the license file. */ -#include <boost/thread.hpp> #include <string> #include "mongo/db/field_parser.h" @@ -37,6 +36,7 @@ #include "mongo/db/service_context.h" #include "mongo/db/write_concern_options.h" #include "mongo/stdx/functional.h" +#include "mongo/stdx/thread.h" #include "mongo/unittest/unittest.h" namespace { @@ -54,6 +54,8 @@ namespace { using mongo::RangeDeleterOptions; using mongo::OperationContext; + namespace stdx = mongo::stdx; + OperationContext* const noTxn = NULL; // MockEnv doesn't need txn XXX SERVER-13931 // Capped sleep interval is 640 mSec, Nyquist frequency is 1280 mSec => round up to 2 sec. @@ -207,7 +209,7 @@ namespace { BSON("x" << 10), BSON("x" << 1))); deleterOption.waitForOpenCursors = true; - boost::thread deleterThread = boost::thread(mongo::stdx::bind( + stdx::thread deleterThread = stdx::thread(mongo::stdx::bind( rangeDeleterDeleteNow, &deleter, noTxn, @@ -264,7 +266,7 @@ namespace { BSON("x" << 10), BSON("x" << 1))); deleterOption.waitForOpenCursors = true; - boost::thread deleterThread = boost::thread(mongo::stdx::bind( + stdx::thread deleterThread = stdx::thread(mongo::stdx::bind( rangeDeleterDeleteNow, &deleter, noTxn, diff --git a/src/mongo/db/repl/base_cloner_test_fixture.cpp b/src/mongo/db/repl/base_cloner_test_fixture.cpp index f083d6df04e..f15775d401e 100644 --- a/src/mongo/db/repl/base_cloner_test_fixture.cpp +++ b/src/mongo/db/repl/base_cloner_test_fixture.cpp @@ -30,9 +30,9 @@ #include "mongo/db/repl/base_cloner_test_fixture.h" -#include <boost/thread.hpp> #include <memory> +#include "mongo/stdx/thread.h" #include "mongo/db/jsobj.h" namespace mongo { 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 8432769a99c..8f0e01ec00b 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 @@ -30,8 +30,6 @@ #include "mongo/platform/basic.h" -#include <boost/thread.hpp> - #include "mongo/base/status.h" #include "mongo/db/jsobj.h" #include "mongo/db/repl/check_quorum_for_config_change.h" @@ -43,6 +41,7 @@ #include "mongo/executor/network_interface_mock.h" #include "mongo/platform/unordered_set.h" #include "mongo/stdx/functional.h" +#include "mongo/stdx/thread.h" #include "mongo/unittest/unittest.h" #include "mongo/util/net/hostandport.h" @@ -83,8 +82,8 @@ namespace { void _runQuorumCheck(const ReplicaSetConfig& config, int myIndex); virtual Status _runQuorumCheckImpl(const ReplicaSetConfig& config, int myIndex) = 0; - std::unique_ptr<boost::thread> _executorThread; - std::unique_ptr<boost::thread> _quorumCheckThread; + std::unique_ptr<stdx::thread> _executorThread; + std::unique_ptr<stdx::thread> _quorumCheckThread; Status _quorumCheckStatus; stdx::mutex _mutex; bool _isQuorumCheckDone; @@ -98,7 +97,7 @@ namespace { _net = new NetworkInterfaceMock; _storage = new StorageInterfaceMock; _executor.reset(new ReplicationExecutor(_net, _storage, 1 /* prng */ )); - _executorThread.reset(new boost::thread(stdx::bind(&ReplicationExecutor::run, + _executorThread.reset(new stdx::thread(stdx::bind(&ReplicationExecutor::run, _executor.get()))); } @@ -110,7 +109,7 @@ namespace { void CheckQuorumTest::startQuorumCheck(const ReplicaSetConfig& config, int myIndex) { ASSERT_FALSE(_quorumCheckThread); _isQuorumCheckDone = false; - _quorumCheckThread.reset(new boost::thread(stdx::bind(&CheckQuorumTest::_runQuorumCheck, + _quorumCheckThread.reset(new stdx::thread(stdx::bind(&CheckQuorumTest::_runQuorumCheck, this, config, myIndex))); diff --git a/src/mongo/db/repl/data_replicator.cpp b/src/mongo/db/repl/data_replicator.cpp index 172e53d3c91..0ae0b6509bf 100644 --- a/src/mongo/db/repl/data_replicator.cpp +++ b/src/mongo/db/repl/data_replicator.cpp @@ -33,7 +33,6 @@ #include "data_replicator.h" #include <algorithm> -#include <boost/thread.hpp> #include <thread> #include "mongo/base/status.h" @@ -45,15 +44,16 @@ #include "mongo/db/repl/database_cloner.h" #include "mongo/db/repl/optime.h" #include "mongo/stdx/functional.h" +#include "mongo/stdx/thread.h" #include "mongo/util/assert_util.h" #include "mongo/util/fail_point_service.h" #include "mongo/util/log.h" +#include "mongo/util/mongoutils/str.h" #include "mongo/util/queue.h" #include "mongo/util/scopeguard.h" #include "mongo/util/stacktrace.h" #include "mongo/util/time_support.h" #include "mongo/util/timer.h" -#include "mongo/util/mongoutils/str.h" namespace mongo { namespace repl { diff --git a/src/mongo/db/repl/data_replicator.h b/src/mongo/db/repl/data_replicator.h index 5833d3bb68f..0cb72021ea8 100644 --- a/src/mongo/db/repl/data_replicator.h +++ b/src/mongo/db/repl/data_replicator.h @@ -29,7 +29,6 @@ #pragma once -#include <boost/thread.hpp> #include <vector> #include "mongo/platform/basic.h" @@ -44,6 +43,7 @@ #include "mongo/db/repl/replication_coordinator.h" #include "mongo/db/repl/replication_executor.h" #include "mongo/db/repl/reporter.h" +#include "mongo/stdx/thread.h" #include "mongo/util/net/hostandport.h" #include "mongo/util/queue.h" diff --git a/src/mongo/db/repl/data_replicator_test.cpp b/src/mongo/db/repl/data_replicator_test.cpp index bcf3022049b..012488dc1a2 100644 --- a/src/mongo/db/repl/data_replicator_test.cpp +++ b/src/mongo/db/repl/data_replicator_test.cpp @@ -182,7 +182,7 @@ namespace { } void run() { - _thread.reset(new boost::thread(stdx::bind(&InitialSyncBackgroundRunner::_run, this))); + _thread.reset(new stdx::thread(stdx::bind(&InitialSyncBackgroundRunner::_run, this))); sleepmillis(2); // sleep to let new thread run initialSync so it schedules work } @@ -196,7 +196,7 @@ namespace { DataReplicator* _dr; TimestampStatus _result; - std::unique_ptr<boost::thread> _thread; + std::unique_ptr<stdx::thread> _thread; }; class InitialSyncTest : public DataReplicatorTest { diff --git a/src/mongo/db/repl/elect_cmd_runner_test.cpp b/src/mongo/db/repl/elect_cmd_runner_test.cpp index 1fc6928382a..c029994f30d 100644 --- a/src/mongo/db/repl/elect_cmd_runner_test.cpp +++ b/src/mongo/db/repl/elect_cmd_runner_test.cpp @@ -28,8 +28,6 @@ #include "mongo/platform/basic.h" -#include <boost/thread.hpp> - #include "mongo/base/status.h" #include "mongo/db/jsobj.h" #include "mongo/db/repl/elect_cmd_runner.h" @@ -39,6 +37,7 @@ #include "mongo/db/repl/storage_interface_mock.h" #include "mongo/executor/network_interface_mock.h" #include "mongo/stdx/functional.h" +#include "mongo/stdx/thread.h" #include "mongo/unittest/unittest.h" @@ -69,7 +68,7 @@ namespace { NetworkInterfaceMock* _net; StorageInterfaceMock* _storage; std::unique_ptr<ReplicationExecutor> _executor; - std::unique_ptr<boost::thread> _executorThread; + std::unique_ptr<stdx::thread> _executorThread; private: void setUp(); @@ -82,7 +81,7 @@ namespace { _net = new NetworkInterfaceMock; _storage = new StorageInterfaceMock; _executor.reset(new ReplicationExecutor(_net, _storage, 1 /* prng seed */)); - _executorThread.reset(new boost::thread(stdx::bind(&ReplicationExecutor::run, + _executorThread.reset(new stdx::thread(stdx::bind(&ReplicationExecutor::run, _executor.get()))); } diff --git a/src/mongo/db/repl/election_winner_declarer_test.cpp b/src/mongo/db/repl/election_winner_declarer_test.cpp index ede769c620d..dfb278f69a1 100644 --- a/src/mongo/db/repl/election_winner_declarer_test.cpp +++ b/src/mongo/db/repl/election_winner_declarer_test.cpp @@ -28,14 +28,13 @@ #include "mongo/platform/basic.h" -#include <boost/thread.hpp> - #include "mongo/base/status.h" #include "mongo/db/jsobj.h" #include "mongo/db/repl/election_winner_declarer.h" #include "mongo/db/repl/replication_executor.h" #include "mongo/executor/network_interface_mock.h" #include "mongo/stdx/functional.h" +#include "mongo/stdx/thread.h" #include "mongo/unittest/unittest.h" #include "mongo/util/mongoutils/str.h" diff --git a/src/mongo/db/repl/freshness_checker_test.cpp b/src/mongo/db/repl/freshness_checker_test.cpp index 9b9b7bc2407..82a266b2910 100644 --- a/src/mongo/db/repl/freshness_checker_test.cpp +++ b/src/mongo/db/repl/freshness_checker_test.cpp @@ -28,8 +28,6 @@ #include "mongo/platform/basic.h" -#include <boost/thread.hpp> - #include "mongo/base/status.h" #include "mongo/db/jsobj.h" #include "mongo/db/repl/freshness_checker.h" @@ -40,6 +38,7 @@ #include "mongo/executor/network_interface_mock.h" #include "mongo/platform/unordered_set.h" #include "mongo/stdx/functional.h" +#include "mongo/stdx/thread.h" #include "mongo/unittest/unittest.h" #include "mongo/util/mongoutils/str.h" @@ -76,7 +75,7 @@ namespace { NetworkInterfaceMock* _net; StorageInterfaceMock* _storage; std::unique_ptr<ReplicationExecutor> _executor; - std::unique_ptr<boost::thread> _executorThread; + std::unique_ptr<stdx::thread> _executorThread; private: void freshnessCheckerRunner(const ReplicationExecutor::CallbackArgs& data, @@ -95,7 +94,7 @@ namespace { _net = new NetworkInterfaceMock; _storage = new StorageInterfaceMock; _executor.reset(new ReplicationExecutor(_net, _storage, 1 /* prng seed */)); - _executorThread.reset(new boost::thread(stdx::bind(&ReplicationExecutor::run, + _executorThread.reset(new stdx::thread(stdx::bind(&ReplicationExecutor::run, _executor.get()))); _checker.reset(new FreshnessChecker); } diff --git a/src/mongo/db/repl/master_slave.cpp b/src/mongo/db/repl/master_slave.cpp index 65f648a2846..b01d74fefe7 100644 --- a/src/mongo/db/repl/master_slave.cpp +++ b/src/mongo/db/repl/master_slave.cpp @@ -43,7 +43,6 @@ #include "mongo/db/repl/master_slave.h" #include <pcrecpp.h> -#include <boost/thread/thread.hpp> #include "mongo/db/auth/authorization_manager.h" #include "mongo/db/auth/authorization_session.h" @@ -55,19 +54,19 @@ #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/dbhelpers.h" -#include "mongo/db/service_context.h" #include "mongo/db/op_observer.h" #include "mongo/db/operation_context_impl.h" #include "mongo/db/ops/update.h" #include "mongo/db/query/internal_plans.h" -#include "mongo/db/repl/repl_client_info.h" #include "mongo/db/repl/handshake_args.h" #include "mongo/db/repl/oplog.h" +#include "mongo/db/repl/repl_client_info.h" #include "mongo/db/repl/replication_coordinator_global.h" #include "mongo/db/repl/sync_tail.h" #include "mongo/db/server_parameters.h" +#include "mongo/db/service_context.h" #include "mongo/db/storage_options.h" -#include "mongo/util/concurrency/old_thread_pool.h" +#include "mongo/stdx/thread.h" #include "mongo/util/exit.h" #include "mongo/util/log.h" @@ -426,7 +425,7 @@ namespace repl { invariant(txn->lockState()->isW()); Lock::TempRelease tempRelease(txn->lockState()); - if (!_connect(&oplogReader, HostAndPort(hostName), + if (!_connect(&oplogReader, HostAndPort(hostName), getGlobalReplicationCoordinator()->getMyRID())) { msgassertedNoTrace( 14051 , "unable to connect to resync"); } @@ -504,12 +503,12 @@ namespace repl { log() << "resync: done with initial clone for db: " << db << endl; } - + static DatabaseIgnorer ___databaseIgnorer; - + void DatabaseIgnorer::doIgnoreUntilAfter( const string &db, const Timestamp &futureOplogTime ) { if ( futureOplogTime > _ignores[ db ] ) { - _ignores[ db ] = futureOplogTime; + _ignores[ db ] = futureOplogTime; } } @@ -533,19 +532,19 @@ namespace repl { // We are already locked at this point if (dbHolder().get(txn, ns) != NULL) { // Database is already present. - return true; + return true; } BSONElement ts = op.getField( "ts" ); if ( ( ts.type() == Date || ts.type() == bsonTimestamp ) && ___databaseIgnorer.ignoreAt( db, ts.timestamp() ) ) { // Database is ignored due to a previous indication that it is // missing from master after optime "ts". - return false; + return false; } if (Database::duplicateUncasedName(db).empty()) { // No duplicate database names are present. return true; } - + Timestamp lastTime; bool dbOk = false; { @@ -556,7 +555,7 @@ namespace repl { // We always log an operation after executing it (never before), so // a database list will always be valid as of an oplog entry generated // before it was retrieved. - + BSONObj last = oplogReader.findOne( this->ns().c_str(), Query().sort( BSON( "$natural" << -1 ) ) ); if ( !last.isEmpty() ) { BSONElement ts = last.getField( "ts" ); @@ -571,34 +570,34 @@ namespace repl { BSONObjIterator i( info.getField( "databases" ).embeddedObject() ); while( i.more() ) { BSONElement e = i.next(); - + const char * name = e.embeddedObject().getField( "name" ).valuestr(); if ( strcasecmp( name, db ) != 0 ) continue; - + if ( strcmp( name, db ) == 0 ) { // The db exists on master, still need to check that no conflicts exist there. dbOk = true; continue; } - + // The master has a db name that conflicts with the requested name. dbOk = false; break; } } - + if ( !dbOk ) { ___databaseIgnorer.doIgnoreUntilAfter( db, lastTime ); incompleteCloneDbs.erase(db); addDbNextPass.erase(db); - return false; + return false; } - + // Check for duplicates again, since we released the lock above. set< string > duplicates; Database::duplicateUncasedName(db, &duplicates); - + // The database is present on the master and no conflicting databases // are present on the master. Drop any local conflicts. for( set< string >::const_iterator i = duplicates.begin(); i != duplicates.end(); ++i ) { @@ -609,7 +608,7 @@ namespace repl { OldClientContext ctx(txn, *i); dropDatabase(txn, ctx.db()); } - + massert(14034, "Duplicate database names present after attempting to delete duplicates", Database::duplicateUncasedName(db).empty()); return true; @@ -745,7 +744,7 @@ namespace repl { } if (!handleDuplicateDbName(txn, op, ns, clientName)) { - return; + return; } // special case apply for commands to avoid implicit database creation @@ -892,7 +891,7 @@ namespace repl { } } } - // obviously global isn't ideal, but non-repl set is old so + // obviously global isn't ideal, but non-repl set is old so // keeping it simple ScopedTransaction transaction(txn, MODE_X); Lock::GlobalWrite lk(txn->lockState()); @@ -1021,7 +1020,7 @@ namespace repl { if ( moreInitialSyncsPending || !oplogReader.more() ) { ScopedTransaction transaction(txn, MODE_X); Lock::GlobalWrite lk(txn->lockState()); - + if (tailing) { okResultCode = 0; // don't sleep } @@ -1132,8 +1131,8 @@ namespace repl { return -1; } - if ( !_connect(&oplogReader, - HostAndPort(hostName), + if ( !_connect(&oplogReader, + HostAndPort(hostName), getGlobalReplicationCoordinator()->getMyRID()) ) { LOG(4) << "can't connect to sync source" << endl; return -1; @@ -1364,13 +1363,13 @@ namespace repl { if ( replSettings.slave ) { verify( replSettings.slave == SimpleSlave ); LOG(1) << "slave=true" << endl; - boost::thread repl_thread(replSlaveThread); + stdx::thread repl_thread(replSlaveThread); } if ( replSettings.master ) { LOG(1) << "master=true" << endl; createOplog(txn); - boost::thread t(replMasterThread); + stdx::thread t(replMasterThread); } if (replSettings.fastsync) { 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 f1d2232988f..a1b5c609bf8 100644 --- a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp @@ -32,7 +32,6 @@ #include "mongo/db/repl/replication_coordinator_external_state_impl.h" -#include <boost/thread.hpp> #include <sstream> #include <string> @@ -44,21 +43,22 @@ #include "mongo/db/concurrency/d_concurrency.h" #include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/db/dbhelpers.h" -#include "mongo/db/service_context.h" #include "mongo/db/jsobj.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/op_observer.h" +#include "mongo/db/operation_context_impl.h" #include "mongo/db/repl/bgsync.h" #include "mongo/db/repl/isself.h" +#include "mongo/db/repl/last_vote.h" #include "mongo/db/repl/master_slave.h" #include "mongo/db/repl/oplog.h" #include "mongo/db/repl/replication_executor.h" #include "mongo/db/repl/rs_sync.h" -#include "mongo/db/repl/last_vote.h" +#include "mongo/db/service_context.h" #include "mongo/db/storage/storage_engine.h" #include "mongo/executor/network_interface.h" #include "mongo/s/d_state.h" #include "mongo/stdx/functional.h" +#include "mongo/stdx/thread.h" #include "mongo/util/assert_util.h" #include "mongo/util/log.h" #include "mongo/util/mongoutils/str.h" @@ -90,11 +90,11 @@ namespace { return; } log() << "Starting replication applier threads"; - _applierThread.reset(new boost::thread(runSyncThread)); + _applierThread.reset(new stdx::thread(runSyncThread)); BackgroundSync* bgsync = BackgroundSync::get(); - _producerThread.reset(new boost::thread(stdx::bind(&BackgroundSync::producerThread, + _producerThread.reset(new stdx::thread(stdx::bind(&BackgroundSync::producerThread, bgsync))); - _syncSourceFeedbackThread.reset(new boost::thread(stdx::bind(&SyncSourceFeedback::run, + _syncSourceFeedbackThread.reset(new stdx::thread(stdx::bind(&SyncSourceFeedback::run, &_syncSourceFeedback))); _startedThreads = true; } diff --git a/src/mongo/db/repl/replication_coordinator_external_state_impl.h b/src/mongo/db/repl/replication_coordinator_external_state_impl.h index 8f5cc27d466..4b08a2c126a 100644 --- a/src/mongo/db/repl/replication_coordinator_external_state_impl.h +++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.h @@ -28,12 +28,11 @@ #pragma once -#include <boost/thread.hpp> - #include "mongo/base/disallow_copying.h" #include "mongo/db/concurrency/d_concurrency.h" #include "mongo/db/repl/replication_coordinator_external_state.h" #include "mongo/db/repl/sync_source_feedback.h" +#include "mongo/stdx/thread.h" namespace mongo { namespace repl { @@ -80,13 +79,13 @@ namespace repl { SyncSourceFeedback _syncSourceFeedback; // Thread running SyncSourceFeedback::run(). - std::unique_ptr<boost::thread> _syncSourceFeedbackThread; + std::unique_ptr<stdx::thread> _syncSourceFeedbackThread; // Thread running runSyncThread(). - std::unique_ptr<boost::thread> _applierThread; + std::unique_ptr<stdx::thread> _applierThread; // Thread running BackgroundSync::producerThread(). - std::unique_ptr<boost::thread> _producerThread; + std::unique_ptr<stdx::thread> _producerThread; // Mutex guarding the _nextThreadId value to prevent concurrent incrementing. stdx::mutex _nextThreadIdMutex; diff --git a/src/mongo/db/repl/replication_coordinator_external_state_mock.h b/src/mongo/db/repl/replication_coordinator_external_state_mock.h index c5e2684d5a3..117e33cd2a4 100644 --- a/src/mongo/db/repl/replication_coordinator_external_state_mock.h +++ b/src/mongo/db/repl/replication_coordinator_external_state_mock.h @@ -28,7 +28,6 @@ #pragma once -#include <boost/thread.hpp> #include <boost/thread/condition.hpp> #include <vector> @@ -37,8 +36,9 @@ #include "mongo/bson/oid.h" #include "mongo/bson/timestamp.h" #include "mongo/db/jsobj.h" -#include "mongo/db/repl/replication_coordinator_external_state.h" #include "mongo/db/repl/last_vote.h" +#include "mongo/db/repl/replication_coordinator_external_state.h" +#include "mongo/stdx/thread.h" #include "mongo/util/net/hostandport.h" namespace mongo { diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp index 19bfba131f4..af29e984e7e 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl.cpp @@ -33,7 +33,6 @@ #include "mongo/db/repl/replication_coordinator_impl.h" #include <algorithm> -#include <boost/thread.hpp> #include <limits> #include "mongo/base/status.h" @@ -47,9 +46,9 @@ #include "mongo/db/repl/freshness_checker.h" #include "mongo/db/repl/handshake_args.h" #include "mongo/db/repl/is_master_response.h" +#include "mongo/db/repl/last_vote.h" #include "mongo/db/repl/read_after_optime_args.h" #include "mongo/db/repl/read_after_optime_response.h" -#include "mongo/db/repl/last_vote.h" #include "mongo/db/repl/repl_client_info.h" #include "mongo/db/repl/repl_set_declare_election_winner_args.h" #include "mongo/db/repl/repl_set_heartbeat_args.h" @@ -67,6 +66,7 @@ #include "mongo/db/server_options.h" #include "mongo/db/write_concern_options.h" #include "mongo/stdx/functional.h" +#include "mongo/stdx/thread.h" #include "mongo/util/assert_util.h" #include "mongo/util/log.h" #include "mongo/util/scopeguard.h" @@ -374,7 +374,7 @@ namespace { return; } - _topCoordDriverThread.reset(new boost::thread(stdx::bind(&ReplicationExecutor::run, + _topCoordDriverThread.reset(new stdx::thread(stdx::bind(&ReplicationExecutor::run, &_replExecutor))); bool doneLoadingConfig = _startLoadLocalConfig(txn); diff --git a/src/mongo/db/repl/replication_coordinator_impl.h b/src/mongo/db/repl/replication_coordinator_impl.h index 2a5f11b410a..2c53a92e936 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.h +++ b/src/mongo/db/repl/replication_coordinator_impl.h @@ -28,7 +28,6 @@ #pragma once -#include <boost/thread.hpp> #include <boost/thread/condition_variable.hpp> #include <vector> #include <memory> @@ -49,6 +48,7 @@ #include "mongo/platform/unordered_map.h" #include "mongo/platform/unordered_set.h" #include "mongo/stdx/mutex.h" +#include "mongo/stdx/thread.h" #include "mongo/util/net/hostandport.h" namespace mongo { @@ -941,7 +941,7 @@ namespace repl { // Thread that drives actions in the topology coordinator // Set in startReplication() and thereafter accessed in shutdown. - std::unique_ptr<boost::thread> _topCoordDriverThread; // (I) + std::unique_ptr<stdx::thread> _topCoordDriverThread; // (I) // Our RID, used to identify us to our sync source when sending replication progress // updates upstream. Set once in startReplication() and then never modified again. diff --git a/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp index 5bf1b40f5cf..5a9eb6ef965 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp @@ -211,7 +211,7 @@ namespace { simulateSuccessfulElection(); Status status(ErrorCodes::InternalError, "Not Set"); - boost::thread reconfigThread(stdx::bind(doReplSetReconfig, getReplCoord(), &status)); + stdx::thread reconfigThread(stdx::bind(doReplSetReconfig, getReplCoord(), &status)); NetworkInterfaceMock* net = getNet(); getNet()->enterNetwork(); @@ -249,7 +249,7 @@ namespace { Status status(ErrorCodes::InternalError, "Not Set"); getExternalState()->setStoreLocalConfigDocumentStatus(Status(ErrorCodes::OutOfDiskSpace, "The test set this")); - boost::thread reconfigThread(stdx::bind(doReplSetReconfig, getReplCoord(), &status)); + stdx::thread reconfigThread(stdx::bind(doReplSetReconfig, getReplCoord(), &status)); NetworkInterfaceMock* net = getNet(); getNet()->enterNetwork(); @@ -286,7 +286,7 @@ namespace { Status status(ErrorCodes::InternalError, "Not Set"); // first reconfig - boost::thread reconfigThread(stdx::bind(doReplSetReconfig, getReplCoord(), &status)); + stdx::thread reconfigThread(stdx::bind(doReplSetReconfig, getReplCoord(), &status)); getNet()->enterNetwork(); getNet()->blackHole(getNet()->getNextReadyRequest()); getNet()->exitNetwork(); @@ -320,7 +320,7 @@ namespace { // initiate Status status(ErrorCodes::InternalError, "Not Set"); - boost::thread initateThread(stdx::bind(doReplSetInitiate, getReplCoord(), &status)); + stdx::thread initateThread(stdx::bind(doReplSetInitiate, getReplCoord(), &status)); getNet()->enterNetwork(); getNet()->blackHole(getNet()->getNextReadyRequest()); getNet()->exitNetwork(); @@ -358,7 +358,7 @@ namespace { simulateSuccessfulElection(); Status status(ErrorCodes::InternalError, "Not Set"); - boost::thread reconfigThread(stdx::bind(doReplSetReconfig, getReplCoord(), &status)); + stdx::thread reconfigThread(stdx::bind(doReplSetReconfig, getReplCoord(), &status)); NetworkInterfaceMock* net = getNet(); getNet()->enterNetwork(); @@ -449,7 +449,7 @@ namespace { // start reconfigThread Status status(ErrorCodes::InternalError, "Not Set"); - boost::thread reconfigThread(stdx::bind(doReplSetReconfig, getReplCoord(), &status)); + stdx::thread reconfigThread(stdx::bind(doReplSetReconfig, getReplCoord(), &status)); // wait for reconfigThread to create network requests to ensure the replication coordinator // is in state kConfigReconfiguring diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp index 9d8144e36dc..e330a1067d2 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp @@ -30,7 +30,6 @@ #include "mongo/platform/basic.h" -#include <boost/thread.hpp> #include <future> #include <iostream> #include <memory> @@ -57,6 +56,7 @@ #include "mongo/db/write_concern_options.h" #include "mongo/executor/network_interface_mock.h" #include "mongo/stdx/functional.h" +#include "mongo/stdx/thread.h" #include "mongo/unittest/unittest.h" #include "mongo/util/assert_util.h" #include "mongo/util/log.h" @@ -242,7 +242,7 @@ namespace { hbArgs.setSenderId(0); Status status(ErrorCodes::InternalError, "Not set"); - boost::thread prsiThread(stdx::bind(doReplSetInitiate, getReplCoord(), &status)); + stdx::thread prsiThread(stdx::bind(doReplSetInitiate, getReplCoord(), &status)); const Date_t startDate = getNet()->now(); getNet()->enterNetwork(); const NetworkInterfaceMock::NetworkOperationIterator noi = getNet()->getNextReadyRequest(); @@ -273,7 +273,7 @@ namespace { hbArgs.setSenderId(0); Status status(ErrorCodes::InternalError, "Not set"); - boost::thread prsiThread(stdx::bind(doReplSetInitiate, getReplCoord(), &status)); + stdx::thread prsiThread(stdx::bind(doReplSetInitiate, getReplCoord(), &status)); const Date_t startDate = getNet()->now(); getNet()->enterNetwork(); const NetworkInterfaceMock::NetworkOperationIterator noi = getNet()->getNextReadyRequest(); @@ -674,7 +674,7 @@ namespace { void start(OperationContext* txn) { ASSERT(!_finished); - _thread.reset(new boost::thread(stdx::bind(&ReplicationAwaiter::_awaitReplication, + _thread.reset(new stdx::thread(stdx::bind(&ReplicationAwaiter::_awaitReplication, this, txn))); } @@ -698,7 +698,7 @@ namespace { OpTime _optime; WriteConcernOptions _writeConcern; ReplicationCoordinator::StatusAndDuration _result; - std::unique_ptr<boost::thread> _thread; + std::unique_ptr<stdx::thread> _thread; }; TEST_F(ReplCoordTest, AwaitReplicationNumberOfNodesBlocking) { @@ -1084,7 +1084,7 @@ namespace { void start(OperationContext* txn) { ASSERT(!_finished); - _thread.reset(new boost::thread(stdx::bind(&StepDownRunner::_stepDown, + _thread.reset(new stdx::thread(stdx::bind(&StepDownRunner::_stepDown, this, txn))); } @@ -1117,7 +1117,7 @@ namespace { ReplicationCoordinatorImpl* _replCoord; bool _finished; Status _result; - std::unique_ptr<boost::thread> _thread; + std::unique_ptr<stdx::thread> _thread; bool _force; Milliseconds _waitTime; Milliseconds _stepDownTime; @@ -1706,7 +1706,7 @@ namespace { // reconfig Status status(ErrorCodes::InternalError, "Not Set"); - boost::thread reconfigThread(stdx::bind(doReplSetReconfig, getReplCoord(), &status)); + stdx::thread reconfigThread(stdx::bind(doReplSetReconfig, getReplCoord(), &status)); NetworkInterfaceMock* net = getNet(); getNet()->enterNetwork(); @@ -1776,7 +1776,7 @@ namespace { // reconfig to fewer nodes Status status(ErrorCodes::InternalError, "Not Set"); - boost::thread reconfigThread(stdx::bind(doReplSetReconfigToFewer, getReplCoord(), &status)); + stdx::thread reconfigThread(stdx::bind(doReplSetReconfigToFewer, getReplCoord(), &status)); NetworkInterfaceMock* net = getNet(); getNet()->enterNetwork(); @@ -1844,7 +1844,7 @@ namespace { // reconfig to three nodes Status status(ErrorCodes::InternalError, "Not Set"); - boost::thread reconfigThread(stdx::bind(doReplSetReconfig, getReplCoord(), &status)); + stdx::thread reconfigThread(stdx::bind(doReplSetReconfig, getReplCoord(), &status)); NetworkInterfaceMock* net = getNet(); getNet()->enterNetwork(); diff --git a/src/mongo/db/repl/replication_executor_test.cpp b/src/mongo/db/repl/replication_executor_test.cpp index af39f824c57..144a1519c89 100644 --- a/src/mongo/db/repl/replication_executor_test.cpp +++ b/src/mongo/db/repl/replication_executor_test.cpp @@ -29,7 +29,6 @@ #include "mongo/platform/basic.h" #include <map> -#include <boost/thread/thread.hpp> #include "mongo/db/namespace_string.h" #include "mongo/db/operation_context.h" @@ -38,6 +37,7 @@ #include "mongo/db/repl/storage_interface_mock.h" #include "mongo/executor/network_interface_mock.h" #include "mongo/stdx/functional.h" +#include "mongo/stdx/thread.h" #include "mongo/unittest/barrier.h" #include "mongo/unittest/unittest.h" #include "mongo/util/assert_util.h" @@ -159,7 +159,7 @@ namespace { NetworkInterfaceMock* net; StorageInterfaceMock* storage; ReplicationExecutor executor; - boost::thread executorThread; + stdx::thread executorThread; const ReplicationExecutor::EventHandle goEvent; const ReplicationExecutor::EventHandle event2; const ReplicationExecutor::EventHandle event3; @@ -213,7 +213,7 @@ namespace { ReplicationExecutor::EventHandle neverSignaledEvent = unittest::assertGet(executor.makeEvent()); - boost::thread neverSignaledWaiter(stdx::bind(&ReplicationExecutor::waitForEvent, + stdx::thread neverSignaledWaiter(stdx::bind(&ReplicationExecutor::waitForEvent, &executor, neverSignaledEvent)); ReplicationExecutor::CallbackHandle shutdownCallback = unittest::assertGet( diff --git a/src/mongo/db/repl/replication_executor_test_fixture.cpp b/src/mongo/db/repl/replication_executor_test_fixture.cpp index ff84a4de538..33b850597bf 100644 --- a/src/mongo/db/repl/replication_executor_test_fixture.cpp +++ b/src/mongo/db/repl/replication_executor_test_fixture.cpp @@ -46,7 +46,7 @@ namespace { void ReplicationExecutorTest::launchExecutorThread() { ASSERT(!_executorThread); _executorThread.reset( - new boost::thread(stdx::bind(&ReplicationExecutor::run, _executor.get()))); + new stdx::thread(stdx::bind(&ReplicationExecutor::run, _executor.get()))); postExecutorThreadLaunch(); } diff --git a/src/mongo/db/repl/replication_executor_test_fixture.h b/src/mongo/db/repl/replication_executor_test_fixture.h index c5e2a9cbc5e..8612db5a1a7 100644 --- a/src/mongo/db/repl/replication_executor_test_fixture.h +++ b/src/mongo/db/repl/replication_executor_test_fixture.h @@ -28,8 +28,7 @@ #pragma once -#include <boost/thread/thread.hpp> - +#include "mongo/stdx/thread.h" #include "mongo/unittest/unittest.h" namespace mongo { @@ -92,7 +91,7 @@ namespace repl { executor::NetworkInterfaceMock* _net; StorageInterfaceMock* _storage; unique_ptr<ReplicationExecutor> _executor; - unique_ptr<boost::thread> _executorThread; + unique_ptr<stdx::thread> _executorThread; }; } // namespace repl diff --git a/src/mongo/db/repl/scatter_gather_test.cpp b/src/mongo/db/repl/scatter_gather_test.cpp index fa00ce05e23..6d3673fa927 100644 --- a/src/mongo/db/repl/scatter_gather_test.cpp +++ b/src/mongo/db/repl/scatter_gather_test.cpp @@ -28,14 +28,13 @@ #include "mongo/platform/basic.h" -#include <boost/thread.hpp> - #include "mongo/db/repl/replication_executor.h" #include "mongo/db/repl/scatter_gather_algorithm.h" #include "mongo/db/repl/scatter_gather_runner.h" #include "mongo/db/repl/storage_interface_mock.h" #include "mongo/executor/network_interface_mock.h" #include "mongo/stdx/functional.h" +#include "mongo/stdx/thread.h" #include "mongo/unittest/unittest.h" namespace mongo { @@ -116,14 +115,14 @@ namespace { NetworkInterfaceMock* _net; StorageInterfaceMock* _storage; std::unique_ptr<ReplicationExecutor> _executor; - std::unique_ptr<boost::thread> _executorThread; + std::unique_ptr<stdx::thread> _executorThread; }; void ScatterGatherTest::setUp() { _net = new NetworkInterfaceMock; _storage = new StorageInterfaceMock; _executor.reset(new ReplicationExecutor(_net, _storage, 1 /* prng seed */)); - _executorThread.reset(new boost::thread(stdx::bind(&ReplicationExecutor::run, + _executorThread.reset(new stdx::thread(stdx::bind(&ReplicationExecutor::run, _executor.get()))); } @@ -149,7 +148,7 @@ namespace { } void run() { - _thread.reset(new boost::thread(stdx::bind(&ScatterGatherRunnerRunner::_run, + _thread.reset(new stdx::thread(stdx::bind(&ScatterGatherRunnerRunner::_run, this, _executor))); } @@ -163,7 +162,7 @@ namespace { ScatterGatherRunner* _sgr; ReplicationExecutor* _executor; Status _result; - std::unique_ptr<boost::thread> _thread; + std::unique_ptr<stdx::thread> _thread; }; // Simple onCompletion function which will toggle a bool, so that we can check the logs to diff --git a/src/mongo/db/sorter/sorter_test.cpp b/src/mongo/db/sorter/sorter_test.cpp index 91f4f7c698d..423baa543fb 100644 --- a/src/mongo/db/sorter/sorter_test.cpp +++ b/src/mongo/db/sorter/sorter_test.cpp @@ -31,9 +31,9 @@ #include "mongo/db/sorter/sorter.h" #include <boost/filesystem.hpp> -#include <boost/thread.hpp> #include "mongo/config.h" +#include "mongo/stdx/thread.h" #include "mongo/unittest/temp_dir.h" #include "mongo/unittest/unittest.h" #include "mongo/util/mongoutils/str.h" @@ -361,7 +361,7 @@ namespace mongo { makeSorter(opts, IWComparator(DESC)) }; - boost::thread inBackground(&Basic::addData, this, sorters[0]); + stdx::thread inBackground(&Basic::addData, this, sorters[0]); addData(sorters[1]); inBackground.join(); diff --git a/src/mongo/db/storage/mmap_v1/dur.cpp b/src/mongo/db/storage/mmap_v1/dur.cpp index e5ba4060a84..24fec0eca41 100644 --- a/src/mongo/db/storage/mmap_v1/dur.cpp +++ b/src/mongo/db/storage/mmap_v1/dur.cpp @@ -74,7 +74,7 @@ #include "mongo/db/storage/mmap_v1/dur.h" #include <boost/thread/condition_variable.hpp> -#include <boost/thread/thread.hpp> + #include <iomanip> #include <utility> @@ -92,6 +92,7 @@ #include "mongo/db/storage/mmap_v1/mmap_v1_options.h" #include "mongo/db/storage_options.h" #include "mongo/stdx/mutex.h" +#include "mongo/stdx/thread.h" #include "mongo/util/concurrency/synchronization.h" #include "mongo/util/exit.h" #include "mongo/util/log.h" @@ -219,7 +220,7 @@ namespace { void start(); private: - boost::thread _durThreadHandle; + stdx::thread _durThreadHandle; }; @@ -605,7 +606,7 @@ namespace { void DurableImpl::start() { // Start the durability thread - boost::thread t(durThread); + stdx::thread t(durThread); _durThreadHandle.swap(t); } diff --git a/src/mongo/db/storage/mmap_v1/dur_journal_writer.cpp b/src/mongo/db/storage/mmap_v1/dur_journal_writer.cpp index 121cbcf9d0e..4c6eb8ec8cc 100644 --- a/src/mongo/db/storage/mmap_v1/dur_journal_writer.cpp +++ b/src/mongo/db/storage/mmap_v1/dur_journal_writer.cpp @@ -33,13 +33,13 @@ #include "mongo/db/storage/mmap_v1/dur_journal_writer.h" #include <boost/bind.hpp> -#include <boost/thread/thread.hpp> #include "mongo/db/client.h" #include "mongo/db/storage/mmap_v1/dur_journal.h" #include "mongo/db/storage/mmap_v1/dur_recover.h" #include "mongo/db/storage/mmap_v1/dur_stats.h" #include "mongo/stdx/functional.h" +#include "mongo/stdx/thread.h" #include "mongo/util/log.h" namespace mongo { @@ -138,7 +138,7 @@ namespace { } // Start the thread - boost::thread t(stdx::bind(&JournalWriter::_journalWriterThread, this)); + stdx::thread t(stdx::bind(&JournalWriter::_journalWriterThread, this)); _journalWriterThreadHandle.swap(t); } diff --git a/src/mongo/db/storage/mmap_v1/dur_journal_writer.h b/src/mongo/db/storage/mmap_v1/dur_journal_writer.h index 9d2b916c0f5..6ac91de6532 100644 --- a/src/mongo/db/storage/mmap_v1/dur_journal_writer.h +++ b/src/mongo/db/storage/mmap_v1/dur_journal_writer.h @@ -28,11 +28,10 @@ #pragma once -#include <boost/thread/thread.hpp> - #include "mongo/base/disallow_copying.h" #include "mongo/db/storage/mmap_v1/aligned_builder.h" #include "mongo/db/storage/mmap_v1/dur_journalformat.h" +#include "mongo/stdx/thread.h" #include "mongo/util/concurrency/synchronization.h" #include "mongo/util/queue.h" @@ -171,7 +170,7 @@ namespace dur { NotifyAll* const _applyToDataFilesNotify; // Wraps and controls the journal writer thread - boost::thread _journalWriterThreadHandle; + stdx::thread _journalWriterThreadHandle; // Indicates that shutdown has been requested. Used for idempotency of the shutdown call. bool _shutdownRequested; diff --git a/src/mongo/db/storage/mmap_v1/dur_preplogbuffer.cpp b/src/mongo/db/storage/mmap_v1/dur_preplogbuffer.cpp index 555b5f8e558..171254eb946 100644 --- a/src/mongo/db/storage/mmap_v1/dur_preplogbuffer.cpp +++ b/src/mongo/db/storage/mmap_v1/dur_preplogbuffer.cpp @@ -38,15 +38,14 @@ #include "mongo/platform/basic.h" -#include <boost/thread.hpp> - #include "mongo/db/storage/mmap_v1/aligned_builder.h" -#include "mongo/db/storage/mmap_v1/durable_mapped_file.h" #include "mongo/db/storage/mmap_v1/dur_commitjob.h" #include "mongo/db/storage/mmap_v1/dur_journal.h" #include "mongo/db/storage/mmap_v1/dur_journalimpl.h" #include "mongo/db/storage/mmap_v1/dur_stats.h" +#include "mongo/db/storage/mmap_v1/durable_mapped_file.h" #include "mongo/db/storage_options.h" +#include "mongo/stdx/thread.h" #include "mongo/util/log.h" #include "mongo/util/mongoutils/str.h" #include "mongo/util/stacktrace.h" diff --git a/src/mongo/db/storage/mmap_v1/file_allocator.cpp b/src/mongo/db/storage/mmap_v1/file_allocator.cpp index 6fb7f61e7e3..f785fa2a456 100644 --- a/src/mongo/db/storage/mmap_v1/file_allocator.cpp +++ b/src/mongo/db/storage/mmap_v1/file_allocator.cpp @@ -33,7 +33,6 @@ #include "mongo/db/storage/mmap_v1/file_allocator.h" -#include <boost/thread.hpp> #include <boost/filesystem/operations.hpp> #include <errno.h> #include <fcntl.h> @@ -54,6 +53,7 @@ #include "mongo/db/storage/paths.h" #include "mongo/platform/posix_fadvise.h" #include "mongo/stdx/functional.h" +#include "mongo/stdx/thread.h" #include "mongo/util/concurrency/thread_name.h" #include "mongo/util/fail_point.h" #include "mongo/util/fail_point_service.h" @@ -121,7 +121,7 @@ namespace mongo { void FileAllocator::start() { - boost::thread t( stdx::bind( &FileAllocator::run , this ) ); + stdx::thread t( stdx::bind( &FileAllocator::run , this ) ); } void FileAllocator::requestAllocation( const string &name, long &size ) { diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp index 92c5415a67a..dcdde08de69 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp @@ -31,12 +31,11 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kStorage -#include <boost/thread.hpp> - #include "mongo/db/storage/wiredtiger/wiredtiger_session_cache.h" #include "mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h" #include "mongo/db/storage/wiredtiger/wiredtiger_util.h" +#include "mongo/stdx/thread.h" #include "mongo/util/log.h" namespace mongo { diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.cpp index 5310fb6836a..bbf12fc075f 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_size_storer.cpp @@ -31,7 +31,6 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kStorage -#include <boost/thread.hpp> #include <wiredtiger.h> #include "mongo/bson/bsonobj.h" @@ -42,6 +41,7 @@ #include "mongo/db/storage/wiredtiger/wiredtiger_session_cache.h" #include "mongo/db/storage/wiredtiger/wiredtiger_size_storer.h" #include "mongo/db/storage/wiredtiger/wiredtiger_util.h" +#include "mongo/stdx/thread.h" #include "mongo/util/log.h" #include "mongo/util/scopeguard.h" diff --git a/src/mongo/dbtests/counttests.cpp b/src/mongo/dbtests/counttests.cpp index 5233c18d2bf..9d192edb7b9 100644 --- a/src/mongo/dbtests/counttests.cpp +++ b/src/mongo/dbtests/counttests.cpp @@ -28,8 +28,6 @@ * then also delete it in the license file. */ -#include <boost/thread/thread.hpp> - #include "mongo/db/catalog/collection.h" #include "mongo/db/db.h" #include "mongo/db/db_raii.h" @@ -37,6 +35,7 @@ #include "mongo/db/dbhelpers.h" #include "mongo/db/json.h" #include "mongo/db/operation_context_impl.h" +#include "mongo/stdx/thread.h" #include "mongo/dbtests/dbtests.h" diff --git a/src/mongo/dbtests/documentsourcetests.cpp b/src/mongo/dbtests/documentsourcetests.cpp index 8713b8cd177..d99e8c6e06a 100644 --- a/src/mongo/dbtests/documentsourcetests.cpp +++ b/src/mongo/dbtests/documentsourcetests.cpp @@ -30,7 +30,6 @@ #include "mongo/platform/basic.h" -#include <boost/thread/thread.hpp> #include <boost/thread/condition.hpp> #include "mongo/db/catalog/collection.h" @@ -44,6 +43,7 @@ #include "mongo/db/query/get_executor.h" #include "mongo/db/storage_options.h" #include "mongo/dbtests/dbtests.h" +#include "mongo/stdx/thread.h" namespace DocumentSourceTests { diff --git a/src/mongo/dbtests/perftests.cpp b/src/mongo/dbtests/perftests.cpp index 0f8fbe2ca8d..459bdb05142 100644 --- a/src/mongo/dbtests/perftests.cpp +++ b/src/mongo/dbtests/perftests.cpp @@ -50,6 +50,7 @@ #include "mongo/config.h" #include "mongo/db/client.h" +#include "mongo/db/concurrency/lock_state.h" #include "mongo/db/db.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/json.h" @@ -57,19 +58,19 @@ #include "mongo/db/operation_context_impl.h" #include "mongo/db/storage/mmap_v1/btree/key.h" #include "mongo/db/storage/mmap_v1/compress.h" -#include "mongo/db/storage/mmap_v1/durable_mapped_file.h" #include "mongo/db/storage/mmap_v1/dur_stats.h" +#include "mongo/db/storage/mmap_v1/durable_mapped_file.h" #include "mongo/db/storage/mmap_v1/mmap.h" #include "mongo/db/storage_options.h" #include "mongo/dbtests/dbtests.h" #include "mongo/dbtests/framework_options.h" +#include "mongo/stdx/thread.h" #include "mongo/util/allocator.h" #include "mongo/util/checksum.h" #include "mongo/util/fail_point.h" #include "mongo/util/log.h" #include "mongo/util/timer.h" #include "mongo/util/version.h" -#include "mongo/db/concurrency/lock_state.h" namespace PerfTests { @@ -407,7 +408,7 @@ namespace PerfTests { return 0; } unsigned long long counter = 0; - boost::thread athread(stdx::bind(&B::thread, this, &counter)); + stdx::thread athread(stdx::bind(&B::thread, this, &counter)); unsigned long long child = launchThreads(remaining - 1); athread.join(); unsigned long long accum = child + counter; @@ -1404,7 +1405,7 @@ namespace PerfTests { All() : Suite( "perf" ) { } Result * run( const string& filter, int runsPerTest ) { - boost::thread a(t); + stdx::thread a(t); Result * res = Suite::run(filter, runsPerTest); a.join(); return res; diff --git a/src/mongo/dbtests/threadedtests.cpp b/src/mongo/dbtests/threadedtests.cpp index daf4f45723a..4f714dd4a10 100644 --- a/src/mongo/dbtests/threadedtests.cpp +++ b/src/mongo/dbtests/threadedtests.cpp @@ -33,7 +33,6 @@ #include "mongo/platform/basic.h" -#include <boost/thread.hpp> #include <boost/version.hpp> #include <iostream> @@ -48,12 +47,13 @@ #include "mongo/stdx/functional.h" #include "mongo/stdx/thread.h" #include "mongo/util/concurrency/mvar.h" -#include "mongo/util/concurrency/rwlock.h" #include "mongo/util/concurrency/old_thread_pool.h" -#include "mongo/util/timer.h" +#include "mongo/util/concurrency/rwlock.h" #include "mongo/util/concurrency/synchronization.h" +#include "mongo/util/concurrency/old_thread_pool.h" #include "mongo/util/concurrency/ticketholder.h" #include "mongo/util/log.h" +#include "mongo/util/timer.h" namespace ThreadedTests { @@ -81,10 +81,10 @@ namespace ThreadedTests { private: void launch_subthreads(int remaining) { - if (!remaining) + if (!remaining) return; - boost::thread athread(stdx::bind(&ThreadedTest::subthread, this, remaining)); + stdx::thread athread(stdx::bind(&ThreadedTest::subthread, this, remaining)); launch_subthreads(remaining - 1); athread.join(); } @@ -136,7 +136,7 @@ namespace ThreadedTests { Lock::GlobalRead r(txn.lockState()); ASSERT(txn.lockState()->isReadLocked()); } - else if( i % 7 == 4 && + else if( i % 7 == 4 && tnumber == 1 /*only one upgrader legal*/ ) { Lock::GlobalWrite w(txn.lockState()); ASSERT( txn.lockState()->isW() ); @@ -173,9 +173,9 @@ namespace ThreadedTests { } } else if( i % 7 == 6 ) { - if( i > N/2 ) { + if( i > N/2 ) { int q = i % 11; - if( q == 0 ) { + if( q == 0 ) { ScopedTransaction scopedXact(&txn, MODE_IS); Lock::DBLock r(txn.lockState(), "foo", MODE_S); @@ -190,7 +190,7 @@ namespace ThreadedTests { } else if( q == 1 ) { // test locking local only -- with no preceding lock - { + { ScopedTransaction scopedXact(&txn, MODE_IS); Lock::DBLock x(txn.lockState(), "local", MODE_S); } @@ -209,7 +209,7 @@ namespace ThreadedTests { Lock::DBLock x(txn.lockState(), "admin", MODE_S); } - { + { ScopedTransaction scopedXact(&txn, MODE_IX); Lock::DBLock x(txn.lockState(), "admin", MODE_X); } @@ -220,13 +220,13 @@ namespace ThreadedTests { Lock::DBLock x(txn.lockState(), "foo", MODE_X); Lock::DBLock y(txn.lockState(), "admin", MODE_S); } - else if( q == 4 ) { + else if( q == 4 ) { ScopedTransaction scopedXact(&txn, MODE_IS); Lock::DBLock x(txn.lockState(), "foo2", MODE_S); Lock::DBLock y(txn.lockState(), "admin", MODE_S); } - else { + else { ScopedTransaction scopedXact(&txn, MODE_IX); Lock::DBLock w(txn.lockState(), "foo", MODE_X); @@ -239,7 +239,7 @@ namespace ThreadedTests { Lock::DBLock r3(txn.lockState(), "local", MODE_S); } } - else { + else { ScopedTransaction scopedXact(&txn, MODE_IS); Lock::DBLock r(txn.lockState(), "foo", MODE_S); @@ -339,9 +339,9 @@ namespace ThreadedTests { } }; - class RWLockTest1 { + class RWLockTest1 { public: - void run() { + void run() { RWLock lk( "eliot" ); { rwlock r( lk , true , 1000 ); @@ -349,7 +349,7 @@ namespace ThreadedTests { } }; - class RWLockTest2 { + class RWLockTest2 { public: static void worker1( RWLockRecursiveNongreedy * lk , AtomicUInt32 * x ) { x->fetchAndAdd(1); // 1 @@ -360,22 +360,22 @@ namespace ThreadedTests { RWLockRecursiveNongreedy::Shared c(*lk); x->fetchAndAdd(1); } - void run() { + void run() { /** * note: this test will deadlock if the code breaks - */ + */ RWLockRecursiveNongreedy lk( "eliot2" , 120 * 1000 ); cout << "RWLock impl: " << lk.implType() << endl; - unique_ptr<RWLockRecursiveNongreedy::Shared> a( new RWLockRecursiveNongreedy::Shared(lk) ); + unique_ptr<RWLockRecursiveNongreedy::Shared> a( new RWLockRecursiveNongreedy::Shared(lk) ); AtomicUInt32 x1(0); cout << "A : " << &x1 << endl; - boost::thread t1( stdx::bind( worker1 , &lk , &x1 ) ); + stdx::thread t1( stdx::bind( worker1 , &lk , &x1 ) ); while ( ! x1.load() ); verify( x1.load() == 1 ); sleepmillis( 500 ); - verify( x1.load() == 1 ); + verify( x1.load() == 1 ); AtomicUInt32 x2(0); - boost::thread t2( stdx::bind( worker2, &lk , &x2 ) ); + stdx::thread t2( stdx::bind( worker2, &lk , &x2 ) ); t2.join(); verify( x2.load() == 1 ); a.reset(); @@ -385,40 +385,40 @@ namespace ThreadedTests { sleepmillis(1); } verify( x1.load() == 2 ); - t1.join(); + t1.join(); } }; - class RWLockTest3 { - public: + class RWLockTest3 { + public: static void worker2( RWLockRecursiveNongreedy * lk , AtomicUInt32 * x ) { verify( ! lk->__lock_try(0) ); RWLockRecursiveNongreedy::Shared c( *lk ); x->fetchAndAdd(1); } - void run() { + void run() { /** * note: this test will deadlock if the code breaks */ - + RWLockRecursiveNongreedy lk( "eliot2" , 120 * 1000 ); - + unique_ptr<RWLockRecursiveNongreedy::Shared> a( new RWLockRecursiveNongreedy::Shared( lk ) ); - + AtomicUInt32 x2(0); - boost::thread t2( stdx::bind( worker2, &lk , &x2 ) ); + stdx::thread t2( stdx::bind( worker2, &lk , &x2 ) ); t2.join(); verify( x2.load() == 1 ); - a.reset(); + a.reset(); } }; - class RWLockTest4 { + class RWLockTest4 { public: - + #if defined(__linux__) || defined(__APPLE__) static void worker1( pthread_rwlock_t * lk , AtomicUInt32 * x ) { x->fetchAndAdd(1); // 1 @@ -441,30 +441,30 @@ namespace ThreadedTests { pthread_rwlock_unlock( lk ); } #endif - void run() { + void run() { /** * note: this test will deadlock if the code breaks */ - -#if defined(__linux__) || defined(__APPLE__) - + +#if defined(__linux__) || defined(__APPLE__) + // create pthread_rwlock_t lk; verify( pthread_rwlock_init( &lk , 0 ) == 0 ); - + // read lock verify( pthread_rwlock_rdlock( &lk ) == 0 ); - + AtomicUInt32 x1(0); - boost::thread t1( stdx::bind( worker1 , &lk , &x1 ) ); + stdx::thread t1( stdx::bind( worker1 , &lk , &x1 ) ); while ( ! x1.load() ); verify( x1.load() == 1 ); sleepmillis( 500 ); verify( x1.load() == 1 ); - + AtomicUInt32 x2(0); - boost::thread t2( stdx::bind( worker2, &lk , &x2 ) ); + stdx::thread t2( stdx::bind( worker2, &lk , &x2 ) ); t2.join(); verify( x2.load() == 1 ); @@ -478,11 +478,11 @@ namespace ThreadedTests { verify( x1.load() == 2 ); t1.join(); -#endif +#endif } }; - // we don't use upgrade so that part is not important currently but the other aspects of this test are + // we don't use upgrade so that part is not important currently but the other aspects of this test are // interesting; it would be nice to do analogous tests for SimpleRWLock and QLock class UpgradableTest : public ThreadedTest<7> { RWLock m; @@ -493,9 +493,9 @@ namespace ThreadedTests { virtual void subthread(int x) { Client::initThread("utest"); - /* r = get a read lock + /* r = get a read lock R = get a read lock and we expect it to be fast - u = get upgradable + u = get upgradable U = get upgradable and we expect it to be fast w = get a write lock */ @@ -510,7 +510,7 @@ namespace ThreadedTests { int Z = 1; LOG(Z) << x << ' ' << what[x] << " request" << endl; char ch = what[x]; - switch( ch ) { + switch( ch ) { case 'w': { m.lock(); @@ -557,8 +557,8 @@ namespace ThreadedTests { m.lock_shared(); LOG(Z) << x << ' ' << ch << " got " << endl; if( what[x] == 'R' ) { - if( t.millis() > 15 ) { - // commented out for less chatter, we aren't using upgradeable anyway right now: + if( t.millis() > 15 ) { + // commented out for less chatter, we aren't using upgradeable anyway right now: // log() << x << " info: when in upgradable, write locks are still greedy on this platform" << endl; } } @@ -573,9 +573,9 @@ namespace ThreadedTests { } }; - void sleepalittle() { + void sleepalittle() { Timer t; - while( 1 ) { + while( 1 ) { stdx::this_thread::yield(); if( t.micros() > 8 ) break; @@ -584,7 +584,7 @@ namespace ThreadedTests { int once; - /* This test is to see how long it takes to get a lock after there has been contention -- the OS + /* This test is to see how long it takes to get a lock after there has been contention -- the OS will need to reschedule us. if a spinlock, it will be fast of course, but these aren't spin locks. Experimenting with different # of threads would be a good idea. */ @@ -606,7 +606,7 @@ namespace ThreadedTests { char pad3[128]; volatile int k; - virtual void validate() { + virtual void validate() { if( once++ == 0 ) { // <= 1.35 we use a different rwmutex impl so worth noting cout << "Boost version : " << BOOST_VERSION << endl; @@ -615,20 +615,20 @@ namespace ThreadedTests { " Slack useful work fraction: " << ((double)a)/b << " locks:" << locks << endl; } void watch() { - while( 1 ) { + while( 1 ) { b++; //__sync_synchronize(); - if( k ) { + if( k ) { a++; } sleepmillis(0); - if( done ) + if( done ) break; } } volatile bool done; virtual void subthread(int x) { - if( x == 1 ) { + if( x == 1 ) { watch(); return; } @@ -663,25 +663,25 @@ namespace ThreadedTests { } private: unsigned a, b; - virtual void validate() { + virtual void validate() { cout << "CondSlack useful work fraction: " << ((double)a)/b << " locks:" << locks << endl; } unsigned locks; volatile int k; void watch() { - while( 1 ) { + while( 1 ) { b++; - if( k ) { + if( k ) { a++; } sleepmillis(0); - if( done ) + if( done ) break; } } volatile bool done; virtual void subthread(int x) { - if( x == 1 ) { + if( x == 1 ) { n.notifyOne(); watch(); return; @@ -693,7 +693,7 @@ namespace ThreadedTests { k = 1; // not very long, we'd like to simulate about 100K locks per second sleepalittle(); - k = 0; + k = 0; locks++; n.notifyOne(); if( done || t.millis() > 1500 ) @@ -715,7 +715,7 @@ namespace ThreadedTests { _barrier.wait(); int Z = 0; Client::initThread("utest"); - if( x == 1 ) { + if( x == 1 ) { LOG(Z) << mongo::curTimeMillis64() % 10000 << " 1" << endl; rwlock_shared lk(m); sleepmillis(400); @@ -819,7 +819,7 @@ namespace ThreadedTests { add< WriteLocksAreGreedy >(); // Slack is a test to see how long it takes for another thread to pick up - // and begin work after another relinquishes the lock. e.g. a spin lock + // and begin work after another relinquishes the lock. e.g. a spin lock // would have very little slack. add< Slack<SimpleMutex,SimpleMutex::scoped_lock> >(); add< Slack<SimpleRWLock,SimpleRWLock::Exclusive> >(); diff --git a/src/mongo/executor/network_interface_impl.cpp b/src/mongo/executor/network_interface_impl.cpp index 95d51e7c264..4e443a45165 100644 --- a/src/mongo/executor/network_interface_impl.cpp +++ b/src/mongo/executor/network_interface_impl.cpp @@ -94,7 +94,7 @@ namespace { const std::string threadName(str::stream() << "ReplExecNetThread-" << _nextThreadId++); try { _threads.push_back( - std::make_shared<boost::thread>( + std::make_shared<stdx::thread>( stdx::bind(&NetworkInterfaceImpl::_requestProcessorThreadBody, this, threadName))); @@ -128,7 +128,7 @@ namespace { _commandRunner.shutdown(); std::for_each(threadsToJoin.begin(), threadsToJoin.end(), - stdx::bind(&boost::thread::join, stdx::placeholders::_1)); + stdx::bind(&stdx::thread::join, stdx::placeholders::_1)); } void NetworkInterfaceImpl::signalWorkAvailable() { diff --git a/src/mongo/executor/network_interface_impl.h b/src/mongo/executor/network_interface_impl.h index 14a421cc8a9..9243dd08127 100644 --- a/src/mongo/executor/network_interface_impl.h +++ b/src/mongo/executor/network_interface_impl.h @@ -29,7 +29,6 @@ #pragma once -#include <boost/thread.hpp> #include <boost/thread/condition_variable.hpp> #include <vector> @@ -37,6 +36,7 @@ #include "mongo/executor/network_interface.h" #include "mongo/stdx/list.h" #include "mongo/stdx/mutex.h" +#include "mongo/stdx/thread.h" namespace mongo { namespace executor { @@ -95,7 +95,7 @@ namespace executor { RemoteCommandCompletionFn onFinish; }; typedef stdx::list<CommandData> CommandDataList; - typedef std::vector<std::shared_ptr<boost::thread> > ThreadList; + typedef std::vector<std::shared_ptr<stdx::thread> > ThreadList; /** * Thread body for threads that synchronously perform network requests from diff --git a/src/mongo/s/catalog/legacy/catalog_manager_legacy.cpp b/src/mongo/s/catalog/legacy/catalog_manager_legacy.cpp index 5074f7830ff..04e1a21ea26 100644 --- a/src/mongo/s/catalog/legacy/catalog_manager_legacy.cpp +++ b/src/mongo/s/catalog/legacy/catalog_manager_legacy.cpp @@ -419,7 +419,7 @@ namespace { "Data inconsistency detected amongst config servers"); } - boost::thread t(stdx::bind(&CatalogManagerLegacy::_consistencyChecker, this)); + stdx::thread t(stdx::bind(&CatalogManagerLegacy::_consistencyChecker, this)); _consistencyCheckerThread.swap(t); return Status::OK(); diff --git a/src/mongo/s/catalog/legacy/catalog_manager_legacy.h b/src/mongo/s/catalog/legacy/catalog_manager_legacy.h index a8744e80c95..6afd75e2026 100644 --- a/src/mongo/s/catalog/legacy/catalog_manager_legacy.h +++ b/src/mongo/s/catalog/legacy/catalog_manager_legacy.h @@ -29,13 +29,13 @@ #pragma once #include <boost/thread/condition.hpp> -#include <boost/thread/thread.hpp> #include <string> #include <vector> #include "mongo/bson/bsonobj.h" #include "mongo/client/connection_string.h" #include "mongo/s/catalog/catalog_manager.h" +#include "mongo/stdx/thread.h" namespace mongo { @@ -201,7 +201,7 @@ namespace mongo { bool _consistentFromLastCheck = false; // Thread that runs dbHash on config servers for checking data consistency. - boost::thread _consistencyCheckerThread; + stdx::thread _consistencyCheckerThread; // condition variable used by the consistency checker thread to wait // for <= 60s, on every iteration, until shutDown is called diff --git a/src/mongo/s/catalog/legacy/legacy_dist_lock_manager.h b/src/mongo/s/catalog/legacy/legacy_dist_lock_manager.h index ce8b4b361a1..5e76df26626 100644 --- a/src/mongo/s/catalog/legacy/legacy_dist_lock_manager.h +++ b/src/mongo/s/catalog/legacy/legacy_dist_lock_manager.h @@ -28,7 +28,6 @@ #pragma once -#include <boost/thread.hpp> #include <map> #include <memory> @@ -38,6 +37,7 @@ #include "mongo/s/catalog/legacy/distlock.h" #include "mongo/s/catalog/legacy/legacy_dist_lock_pinger.h" #include "mongo/stdx/memory.h" +#include "mongo/stdx/thread.h" namespace mongo { diff --git a/src/mongo/s/catalog/legacy/legacy_dist_lock_pinger.cpp b/src/mongo/s/catalog/legacy/legacy_dist_lock_pinger.cpp index 2fcc3af1428..5e5f03b0864 100644 --- a/src/mongo/s/catalog/legacy/legacy_dist_lock_pinger.cpp +++ b/src/mongo/s/catalog/legacy/legacy_dist_lock_pinger.cpp @@ -32,12 +32,11 @@ #include "mongo/s/catalog/legacy/legacy_dist_lock_pinger.h" -#include <boost/thread.hpp> - #include "mongo/client/connpool.h" #include "mongo/s/catalog/legacy/distlock.h" #include "mongo/s/type_lockpings.h" #include "mongo/s/type_locks.h" +#include "mongo/stdx/thread.h" #include "mongo/util/exit.h" #include "mongo/util/log.h" @@ -264,7 +263,7 @@ namespace { { stdx::lock_guard<stdx::mutex> lk(_mutex); - boost::thread thread(stdx::bind(&LegacyDistLockPinger::distLockPingThread, + stdx::thread thread(stdx::bind(&LegacyDistLockPinger::distLockPingThread, this, conn, getJSTimeVirtualThreadSkew(), diff --git a/src/mongo/s/catalog/legacy/legacy_dist_lock_pinger.h b/src/mongo/s/catalog/legacy/legacy_dist_lock_pinger.h index e7dec414bb9..261f695d8ae 100644 --- a/src/mongo/s/catalog/legacy/legacy_dist_lock_pinger.h +++ b/src/mongo/s/catalog/legacy/legacy_dist_lock_pinger.h @@ -28,7 +28,6 @@ #pragma once -#include <boost/thread/thread.hpp> #include <list> #include <set> #include <string> @@ -37,6 +36,7 @@ #include "mongo/client/dbclientinterface.h" #include "mongo/s/catalog/dist_lock_manager.h" #include "mongo/stdx/memory.h" +#include "mongo/stdx/thread.h" #include "mongo/util/concurrency/mutex.h" #include "mongo/util/time_support.h" @@ -122,7 +122,7 @@ namespace mongo { // This can contain multiple elements in tests, but in tne normal case, this will // contain only a single element. // Note: can be safely read when _inShutdown is true. - std::map<std::string, boost::thread> _pingThreads; // (M*) + std::map<std::string, stdx::thread> _pingThreads; // (M*) // Contains the list of process id to stopPing. std::set<std::string> _kill; // (M) diff --git a/src/mongo/s/client/multi_host_query.cpp b/src/mongo/s/client/multi_host_query.cpp index 9da64c16f1e..2fcb5906bf4 100644 --- a/src/mongo/s/client/multi_host_query.cpp +++ b/src/mongo/s/client/multi_host_query.cpp @@ -55,7 +55,7 @@ namespace mongo { // dispatching pool has already been disposed. // - _threads.push_back(new boost::thread(stdx::bind(&HostThreadPool::doWork, _context))); + _threads.push_back(new stdx::thread(stdx::bind(&HostThreadPool::doWork, _context))); } } @@ -120,7 +120,7 @@ namespace mongo { DESTRUCTOR_GUARD( _context->workScheduledCV.notify_all(); ) - for (vector<boost::thread*>::iterator it = _threads.begin(); it != _threads.end(); ++it) { + for (vector<stdx::thread*>::iterator it = _threads.begin(); it != _threads.end(); ++it) { if (_scopeAllWork) { DESTRUCTOR_GUARD( ( *it )->join(); ) diff --git a/src/mongo/s/client/multi_host_query.h b/src/mongo/s/client/multi_host_query.h index 9a9585e4f88..bfd23953e25 100644 --- a/src/mongo/s/client/multi_host_query.h +++ b/src/mongo/s/client/multi_host_query.h @@ -29,13 +29,13 @@ #pragma once #include <boost/thread/condition_variable.hpp> -#include <boost/thread/thread.hpp> #include <vector> #include "mongo/base/disallow_copying.h" #include "mongo/client/dbclientinterface.h" #include "mongo/stdx/functional.h" #include "mongo/stdx/mutex.h" +#include "mongo/stdx/thread.h" namespace mongo { @@ -320,7 +320,7 @@ namespace mongo { const bool _scopeAllWork; // For now, only modified in the constructor and destructor, but non-const - std::vector<boost::thread*> _threads; + std::vector<stdx::thread*> _threads; // Shared work and worker activity information std::shared_ptr<PoolContext> _context; diff --git a/src/mongo/s/client/shard_connection_test.cpp b/src/mongo/s/client/shard_connection_test.cpp index 70257bb217c..1751dd1c84e 100644 --- a/src/mongo/s/client/shard_connection_test.cpp +++ b/src/mongo/s/client/shard_connection_test.cpp @@ -25,6 +25,8 @@ * then also delete it in the license file. */ +#include <vector> + #include "mongo/base/init.h" #include "mongo/client/connpool.h" #include "mongo/db/auth/authorization_manager.h" @@ -38,11 +40,9 @@ #include "mongo/platform/cstdint.h" #include "mongo/s/client/shard_connection.h" #include "mongo/stdx/memory.h" +#include "mongo/stdx/thread.h" #include "mongo/unittest/unittest.h" -#include <vector> -#include <boost/thread/thread.hpp> - /** * Tests for ShardConnection, particularly in connection pool management. * The tests focuses more on ShardConnection's logic as opposed to testing diff --git a/src/mongo/s/distlock_test.cpp b/src/mongo/s/distlock_test.cpp index 8cf82627a46..46c385035dc 100644 --- a/src/mongo/s/distlock_test.cpp +++ b/src/mongo/s/distlock_test.cpp @@ -33,7 +33,6 @@ #include "mongo/s/catalog/legacy/distlock.h" -#include <boost/thread/thread.hpp> #include <iostream> #include <vector> @@ -45,6 +44,7 @@ #include "mongo/db/commands.h" #include "mongo/platform/atomic_word.h" #include "mongo/s/catalog/legacy/legacy_dist_lock_pinger.h" +#include "mongo/stdx/thread.h" #include "mongo/util/bson_util.h" #include "mongo/util/concurrency/thread_name.h" #include "mongo/util/log.h" @@ -302,11 +302,11 @@ namespace mongo { count.store(0); keepGoing.store(true); - vector<shared_ptr<boost::thread> > threads; + vector<shared_ptr<stdx::thread> > threads; vector<shared_ptr<BSONObjBuilder> > results; for (int i = 0; i < numThreads; i++) { results.push_back(shared_ptr<BSONObjBuilder> (new BSONObjBuilder())); - threads.push_back(shared_ptr<boost::thread> (new boost::thread( + threads.push_back(shared_ptr<stdx::thread> (new stdx::thread( stdx::bind(&TestDistLockWithSkew::runThread, this, hostConn, (unsigned) i, seed + i, boost::ref(cmdObj), boost::ref(*(results[i].get())))))); diff --git a/src/mongo/s/server.cpp b/src/mongo/s/server.cpp index 4c1b9d810fd..a9c0f1857fb 100644 --- a/src/mongo/s/server.cpp +++ b/src/mongo/s/server.cpp @@ -32,8 +32,6 @@ #include "mongo/s/server.h" -#include <boost/thread/thread.hpp> - #include "mongo/base/init.h" #include "mongo/base/initializer.h" #include "mongo/base/status.h" @@ -62,8 +60,8 @@ #include "mongo/platform/process_id.h" #include "mongo/s/balance.h" #include "mongo/s/catalog/legacy/catalog_manager_legacy.h" -#include "mongo/s/client/sharding_connection_hook.h" #include "mongo/s/client/shard_registry.h" +#include "mongo/s/client/sharding_connection_hook.h" #include "mongo/s/config.h" #include "mongo/s/cursors.h" #include "mongo/s/grid.h" @@ -71,6 +69,7 @@ #include "mongo/s/request.h" #include "mongo/s/version_mongos.h" #include "mongo/stdx/memory.h" +#include "mongo/stdx/thread.h" #include "mongo/util/admin_access.h" #include "mongo/util/cmdline_utils/censor_cmdline.h" #include "mongo/util/concurrency/thread_name.h" @@ -265,7 +264,7 @@ static ExitCode runMongosServer( bool doUpgrade ) { new NoAdminAccess())); dbWebServer->setupSockets(); - boost::thread web(stdx::bind(&webServerListenThread, dbWebServer)); + stdx::thread web(stdx::bind(&webServerListenThread, dbWebServer)); web.detach(); } diff --git a/src/mongo/scripting/v8-3.25_utils.cpp b/src/mongo/scripting/v8-3.25_utils.cpp index f18de5c4bd8..a0b974c22a3 100644 --- a/src/mongo/scripting/v8-3.25_utils.cpp +++ b/src/mongo/scripting/v8-3.25_utils.cpp @@ -32,7 +32,6 @@ #include "mongo/scripting/v8-3.25_utils.h" #include <boost/thread/condition_variable.hpp> -#include <boost/thread/thread.hpp> #include <iostream> #include <map> #include <sstream> @@ -42,6 +41,7 @@ #include "mongo/scripting/engine_v8-3.25.h" #include "mongo/scripting/v8-3.25_db.h" #include "mongo/stdx/mutex.h" +#include "mongo/stdx/thread.h" #include "mongo/util/log.h" #include "mongo/util/mongoutils/str.h" @@ -121,7 +121,7 @@ namespace mongo { void start() { jsassert(!_started, "Thread already started"); JSThread jt(*this); - _thread.reset(new boost::thread(jt)); + _thread.reset(new stdx::thread(jt)); _started = true; } void join() { @@ -237,7 +237,7 @@ namespace mongo { bool _started; bool _done; - unique_ptr<boost::thread> _thread; + unique_ptr<stdx::thread> _thread; std::shared_ptr<SharedData> _sharedData; }; diff --git a/src/mongo/scripting/v8_deadline_monitor.h b/src/mongo/scripting/v8_deadline_monitor.h index ee1b6a63daa..1ebc096fed8 100644 --- a/src/mongo/scripting/v8_deadline_monitor.h +++ b/src/mongo/scripting/v8_deadline_monitor.h @@ -27,12 +27,12 @@ */ #pragma once -#include <boost/thread/thread.hpp> #include <boost/thread/condition.hpp> #include "mongo/base/disallow_copying.h" #include "mongo/platform/cstdint.h" #include "mongo/platform/unordered_map.h" +#include "mongo/stdx/thread.h" #include "mongo/util/concurrency/mutex.h" #include "mongo/util/time_support.h" @@ -71,7 +71,7 @@ namespace mongo { // should not create the thread in the initializer list. Creating it there leaves us // vulnerable to errors introduced by rearranging the order of fields in the class. _monitorThread = - boost::thread(&mongo::DeadlineMonitor<_Task>::deadlineMonitorThread, this); + stdx::thread(&mongo::DeadlineMonitor<_Task>::deadlineMonitorThread, this); } ~DeadlineMonitor() { @@ -162,10 +162,9 @@ namespace mongo { TaskDeadlineMap _tasks; // map of running tasks with deadlines stdx::mutex _deadlineMutex; // protects all non-const members, except _monitorThread boost::condition_variable _newDeadlineAvailable; // Signaled for timeout, start and stop - boost::thread _monitorThread; // the deadline monitor thread + stdx::thread _monitorThread; // the deadline monitor thread Date_t _nearestDeadlineWallclock = Date_t::max(); // absolute time of the nearest deadline bool _inShutdown = false; }; } // namespace mongo - diff --git a/src/mongo/scripting/v8_utils.cpp b/src/mongo/scripting/v8_utils.cpp index 53420b814b7..0dd6c087cd4 100644 --- a/src/mongo/scripting/v8_utils.cpp +++ b/src/mongo/scripting/v8_utils.cpp @@ -32,7 +32,6 @@ #include "mongo/scripting/v8_utils.h" #include <boost/thread/condition_variable.hpp> -#include <boost/thread/thread.hpp> #include <iostream> #include <map> #include <sstream> @@ -42,6 +41,7 @@ #include "mongo/scripting/engine_v8.h" #include "mongo/scripting/v8_db.h" #include "mongo/stdx/mutex.h" +#include "mongo/stdx/thread.h" #include "mongo/util/log.h" #include "mongo/util/mongoutils/str.h" @@ -120,7 +120,7 @@ namespace mongo { void start() { jsassert(!_started, "Thread already started"); JSThread jt(*this); - _thread.reset(new boost::thread(jt)); + _thread.reset(new stdx::thread(jt)); _started = true; } void join() { @@ -234,7 +234,7 @@ namespace mongo { bool _started; bool _done; - unique_ptr<boost::thread> _thread; + unique_ptr<stdx::thread> _thread; std::shared_ptr<SharedData> _sharedData; }; diff --git a/src/mongo/shell/bench.cpp b/src/mongo/shell/bench.cpp index 3fb31c2b0ad..6fc881f350a 100644 --- a/src/mongo/shell/bench.cpp +++ b/src/mongo/shell/bench.cpp @@ -35,18 +35,17 @@ #include "mongo/shell/bench.h" #include <pcrecpp.h> - -#include <boost/thread/thread.hpp> #include <iostream> -#include "mongo/db/namespace_string.h" #include "mongo/client/dbclientcursor.h" +#include "mongo/db/namespace_string.h" #include "mongo/scripting/bson_template_evaluator.h" #include "mongo/scripting/engine.h" +#include "mongo/stdx/thread.h" #include "mongo/util/log.h" #include "mongo/util/md5.h" -#include "mongo/util/timer.h" #include "mongo/util/time_support.h" +#include "mongo/util/timer.h" #include "mongo/util/version.h" // --------------------------------- @@ -341,7 +340,7 @@ namespace mongo { BenchRunWorker::~BenchRunWorker() {} void BenchRunWorker::start() { - boost::thread(stdx::bind(&BenchRunWorker::run, this)); + stdx::thread(stdx::bind(&BenchRunWorker::run, this)); } bool BenchRunWorker::shouldStop() const { diff --git a/src/mongo/shell/clientAndShell.cpp b/src/mongo/shell/clientAndShell.cpp index a7ee344a03e..07f9b5cd83a 100644 --- a/src/mongo/shell/clientAndShell.cpp +++ b/src/mongo/shell/clientAndShell.cpp @@ -31,9 +31,8 @@ #include "mongo/platform/basic.h" -#include <boost/thread.hpp> - #include "mongo/shell/shell_utils.h" +#include "mongo/stdx/thread.h" #include "mongo/util/assert_util.h" #include "mongo/util/log.h" #include "mongo/util/quick_exit.h" diff --git a/src/mongo/shell/shell_utils.h b/src/mongo/shell/shell_utils.h index 06a43e0b936..88ba5235013 100644 --- a/src/mongo/shell/shell_utils.h +++ b/src/mongo/shell/shell_utils.h @@ -29,8 +29,6 @@ #pragma once -#include <boost/thread/mutex.hpp> - #include "mongo/db/jsobj.h" #include "mongo/stdx/mutex.h" #include "mongo/util/concurrency/mutex.h" diff --git a/src/mongo/shell/shell_utils_launcher.cpp b/src/mongo/shell/shell_utils_launcher.cpp index ec36051859c..6d4991e999a 100644 --- a/src/mongo/shell/shell_utils_launcher.cpp +++ b/src/mongo/shell/shell_utils_launcher.cpp @@ -33,7 +33,6 @@ #include "mongo/shell/shell_utils_launcher.h" -#include <boost/thread/thread.hpp> #include <iostream> #include <map> #include <signal.h> @@ -54,6 +53,7 @@ #include "mongo/client/dbclientinterface.h" #include "mongo/scripting/engine.h" #include "mongo/shell/shell_utils.h" +#include "mongo/stdx/thread.h" #include "mongo/util/log.h" #include "mongo/util/quick_exit.h" #include "mongo/util/scopeguard.h" @@ -550,14 +550,14 @@ namespace mongo { _nokillop = true; ProgramRunner r( a ); r.start(); - boost::thread t( r ); + stdx::thread t( r ); return BSON( string( "" ) << r.pid().asLongLong() ); } BSONObj RunMongoProgram( const BSONObj &a, void* data ) { ProgramRunner r( a ); r.start(); - boost::thread t( r ); + stdx::thread t( r ); int exit_code = -123456; // sentinel value wait_for_pid( r.pid(), true, &exit_code ); if ( r.port() > 0 ) { @@ -572,7 +572,7 @@ namespace mongo { BSONObj RunProgram(const BSONObj &a, void* data) { ProgramRunner r( a ); r.start(); - boost::thread t( r ); + stdx::thread t( r ); int exit_code = -123456; // sentinel value wait_for_pid(r.pid(), true, &exit_code); registry.deletePid( r.pid() ); diff --git a/src/mongo/tools/bridge.cpp b/src/mongo/tools/bridge.cpp index 2644ccc8eaf..2114dbc72c3 100644 --- a/src/mongo/tools/bridge.cpp +++ b/src/mongo/tools/bridge.cpp @@ -30,19 +30,19 @@ #include "mongo/platform/basic.h" -#include <boost/thread.hpp> #include <iostream> #include <signal.h> #include "mongo/base/initializer.h" #include "mongo/client/dbclientinterface.h" #include "mongo/db/dbmessage.h" +#include "mongo/stdx/thread.h" #include "mongo/tools/mongobridge_options.h" #include "mongo/util/log.h" #include "mongo/util/net/listen.h" #include "mongo/util/net/message.h" -#include "mongo/util/stacktrace.h" #include "mongo/util/quick_exit.h" +#include "mongo/util/stacktrace.h" #include "mongo/util/text.h" #include "mongo/util/timer.h" @@ -139,7 +139,7 @@ public: virtual void acceptedMP(MessagingPort *mp) { ports.insert( mp ); Forwarder f( *mp ); - boost::thread t( f ); + stdx::thread t( f ); } }; diff --git a/src/mongo/util/background_job_test.cpp b/src/mongo/util/background_job_test.cpp index 4e695dc5e1f..8d3ca7cd356 100644 --- a/src/mongo/util/background_job_test.cpp +++ b/src/mongo/util/background_job_test.cpp @@ -27,9 +27,8 @@ #include "mongo/platform/basic.h" -#include <boost/thread/thread.hpp> - #include "mongo/db/server_options.h" +#include "mongo/stdx/thread.h" #include "mongo/unittest/unittest.h" #include "mongo/util/background.h" #include "mongo/util/concurrency/mutex.h" diff --git a/src/mongo/util/concurrency/old_thread_pool.cpp b/src/mongo/util/concurrency/old_thread_pool.cpp index b1403d446f3..e25855770eb 100644 --- a/src/mongo/util/concurrency/old_thread_pool.cpp +++ b/src/mongo/util/concurrency/old_thread_pool.cpp @@ -31,10 +31,9 @@ #include "mongo/util/concurrency/old_thread_pool.h" -#include <boost/thread/thread.hpp> - -#include "mongo/util/concurrency/mvar.h" +#include "mongo/stdx/thread.h" #include "mongo/util/assert_util.h" +#include "mongo/util/concurrency/mvar.h" #include "mongo/util/log.h" #include "mongo/util/mongoutils/str.h" @@ -68,7 +67,7 @@ private: OldThreadPool& _owner; MVar<Task> _task; bool _is_done; // only used for error detection - boost::thread _thread; + stdx::thread _thread; void loop(const std::string& threadName) { setThreadName(threadName); @@ -109,7 +108,7 @@ OldThreadPool::OldThreadPool(const DoNotStartThreadsTag&, } void OldThreadPool::startThreads() { - boost::lock_guard<boost::mutex> lock(_mutex); + stdx::lock_guard<stdx::mutex> lock(_mutex); for (int i = 0; i < _nThreads; ++i) { const std::string threadName(_threadNamePrefix.empty() ? _threadNamePrefix : @@ -137,14 +136,14 @@ OldThreadPool::~OldThreadPool() { } void OldThreadPool::join() { - boost::unique_lock<boost::mutex> lock(_mutex); + stdx::unique_lock<stdx::mutex> lock(_mutex); while(_tasksRemaining) { _condition.wait(lock); } } void OldThreadPool::schedule(Task task) { - boost::lock_guard<boost::mutex> lock(_mutex); + stdx::lock_guard<stdx::mutex> lock(_mutex); _tasksRemaining++; @@ -159,7 +158,7 @@ void OldThreadPool::schedule(Task task) { // should only be called by a worker from the worker thread void OldThreadPool::task_done(Worker* worker) { - boost::lock_guard<boost::mutex> lock(_mutex); + stdx::lock_guard<stdx::mutex> lock(_mutex); if (!_tasks.empty()) { worker->set_task(_tasks.front()); diff --git a/src/mongo/util/concurrency/old_thread_pool.h b/src/mongo/util/concurrency/old_thread_pool.h index aaf918e15fa..963ce2ff4ac 100644 --- a/src/mongo/util/concurrency/old_thread_pool.h +++ b/src/mongo/util/concurrency/old_thread_pool.h @@ -31,10 +31,10 @@ #include <string> #include <boost/thread/condition.hpp> -#include <boost/thread/mutex.hpp> #include "mongo/base/disallow_copying.h" #include "mongo/stdx/functional.h" +#include "mongo/stdx/mutex.h" namespace mongo { @@ -86,7 +86,7 @@ namespace mongo { private: class Worker; - boost::mutex _mutex; + stdx::mutex _mutex; boost::condition _condition; std::list<Worker*> _freeWorkers; //used as LIFO stack (always front) diff --git a/src/mongo/util/concurrency/spin_lock_test.cpp b/src/mongo/util/concurrency/spin_lock_test.cpp index 75ec3cf9e24..9fef554f352 100644 --- a/src/mongo/util/concurrency/spin_lock_test.cpp +++ b/src/mongo/util/concurrency/spin_lock_test.cpp @@ -26,9 +26,8 @@ * then also delete it in the license file. */ -#include <boost/thread/thread.hpp> - #include "mongo/stdx/functional.h" +#include "mongo/stdx/thread.h" #include "mongo/unittest/unittest.h" #include "mongo/util/concurrency/spin_lock.h" #include "mongo/util/timer.h" @@ -38,6 +37,8 @@ namespace { using mongo::SpinLock; using mongo::Timer; + namespace stdx = mongo::stdx; + class LockTester { public: LockTester( SpinLock* spin, int* counter ) @@ -48,7 +49,7 @@ namespace { } void start( int increments ) { - _t = new boost::thread( mongo::stdx::bind(&LockTester::test, this, increments) ); + _t = new stdx::thread( mongo::stdx::bind(&LockTester::test, this, increments) ); } void join() { @@ -63,7 +64,7 @@ namespace { SpinLock* _spin; // not owned here int* _counter; // not owned here int _requests; - boost::thread* _t; + stdx::thread* _t; void test( int increments ) { while ( increments-- > 0 ) { diff --git a/src/mongo/util/fail_point.cpp b/src/mongo/util/fail_point.cpp index dac1813c09f..56283065348 100644 --- a/src/mongo/util/fail_point.cpp +++ b/src/mongo/util/fail_point.cpp @@ -30,9 +30,8 @@ #include "mongo/util/fail_point.h" -#include <boost/thread.hpp> - #include "mongo/platform/random.h" +#include "mongo/stdx/thread.h" #include "mongo/util/concurrency/threadlocal.h" #include "mongo/util/log.h" #include "mongo/util/mongoutils/str.h" diff --git a/src/mongo/util/fail_point_test.cpp b/src/mongo/util/fail_point_test.cpp index 4fd44643cd9..0b06cb7167d 100644 --- a/src/mongo/util/fail_point_test.cpp +++ b/src/mongo/util/fail_point_test.cpp @@ -30,12 +30,12 @@ #include "mongo/platform/basic.h" -#include <boost/thread/thread.hpp> #include <stdexcept> #include <string> #include <vector> #include "mongo/stdx/functional.h" +#include "mongo/stdx/thread.h" #include "mongo/unittest/unittest.h" #include "mongo/util/fail_point.h" #include "mongo/util/log.h" @@ -256,7 +256,7 @@ namespace mongo_test { } FailPoint _fp; - std::vector<boost::thread> _tasks; + std::vector<stdx::thread> _tasks; stdx::mutex _mutex; bool _inShutdown = false; }; @@ -295,11 +295,11 @@ namespace mongo_test { ASSERT_GT(numEncountersPerThread, 0); FailPoint failPoint; failPoint.setMode(fpMode, fpVal); - std::vector<boost::thread*> tasks; + std::vector<stdx::thread*> tasks; std::vector<int64_t> counts(numThreads, 0); ASSERT_EQUALS(static_cast<uint32_t>(numThreads), counts.size()); for (int32_t i = 0; i < numThreads; ++i) { - tasks.push_back(new boost::thread(parallelFailPointTestThread, + tasks.push_back(new stdx::thread(parallelFailPointTestThread, &failPoint, numEncountersPerThread, i, // hardcoded seed, different for each thread. diff --git a/src/mongo/util/net/message_server_port.cpp b/src/mongo/util/net/message_server_port.cpp index f6e5f95a44e..7c176c66764 100644 --- a/src/mongo/util/net/message_server_port.cpp +++ b/src/mongo/util/net/message_server_port.cpp @@ -31,7 +31,6 @@ #include "mongo/platform/basic.h" -#include <boost/thread/thread.hpp> #include <memory> #include "mongo/base/disallow_copying.h" @@ -40,6 +39,7 @@ #include "mongo/db/server_options.h" #include "mongo/db/stats/counters.h" #include "mongo/stdx/functional.h" +#include "mongo/stdx/thread.h" #include "mongo/util/concurrency/synchronization.h" #include "mongo/util/concurrency/thread_name.h" #include "mongo/util/concurrency/ticketholder.h" @@ -115,7 +115,7 @@ namespace { try { #ifndef __linux__ // TODO: consider making this ifdef _WIN32 { - boost::thread thr(stdx::bind(&handleIncomingMsg, portWithHandler.get())); + stdx::thread thr(stdx::bind(&handleIncomingMsg, portWithHandler.get())); } #else pthread_attr_t attrs; diff --git a/src/mongo/util/net/sock_test.cpp b/src/mongo/util/net/sock_test.cpp index dbc42903915..0a823e15f23 100644 --- a/src/mongo/util/net/sock_test.cpp +++ b/src/mongo/util/net/sock_test.cpp @@ -30,8 +30,6 @@ #include "mongo/util/net/sock.h" -#include <boost/thread.hpp> - #ifndef _WIN32 #include <netdb.h> #include <sys/socket.h> @@ -39,6 +37,7 @@ #endif #include "mongo/db/server_options.h" +#include "mongo/stdx/thread.h" #include "mongo/unittest/unittest.h" #include "mongo/util/concurrency/synchronization.h" #include "mongo/util/fail_point_service.h" @@ -147,12 +146,12 @@ namespace { Notification accepted; SOCKET acceptSock = INVALID_SOCKET; - boost::thread acceptor( + stdx::thread acceptor( stdx::bind(&detail::awaitAccept, &acceptSock, listenSock, boost::ref(accepted))); Notification connected; SOCKET connectSock = INVALID_SOCKET; - boost::thread connector( + stdx::thread connector( stdx::bind(&detail::awaitConnect, &connectSock, *connectRes, boost::ref(connected))); connected.waitToBeNotified(); diff --git a/src/mongo/util/ntservice.cpp b/src/mongo/util/ntservice.cpp index 7aafb2681fb..41dde9d15c3 100644 --- a/src/mongo/util/ntservice.cpp +++ b/src/mongo/util/ntservice.cpp @@ -531,7 +531,7 @@ namespace { // On client OSes, SERVICE_CONTROL_SHUTDOWN has a 5 second timeout configured in // HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control static void serviceStop() { - boost::thread serviceWorkerThread(serviceStopWorker); + stdx::thread serviceWorkerThread(serviceStopWorker); // We periodically check if we are done exiting by polling at half of each wait interval // diff --git a/src/mongo/util/signal_handlers.cpp b/src/mongo/util/signal_handlers.cpp index 51dbbcc2525..ab34d0033f1 100644 --- a/src/mongo/util/signal_handlers.cpp +++ b/src/mongo/util/signal_handlers.cpp @@ -32,7 +32,6 @@ #include "mongo/util/signal_handlers.h" -#include <boost/thread.hpp> #include <signal.h> #if !defined(_WIN32) @@ -43,6 +42,7 @@ #include "mongo/db/log_process_details.h" #include "mongo/db/server_options.h" #include "mongo/platform/process_id.h" +#include "mongo/stdx/thread.h" #include "mongo/util/assert_util.h" #include "mongo/util/exit_code.h" #include "mongo/util/log.h" @@ -213,12 +213,12 @@ namespace { void startSignalProcessingThread() { #ifdef _WIN32 - boost::thread(eventProcessingThread).detach(); + stdx::thread(eventProcessingThread).detach(); #else // Mask signals in the current (only) thread. All new threads will inherit this mask. invariant( pthread_sigmask( SIG_SETMASK, &asyncSignals, 0 ) == 0 ); // Spawn a thread to capture the signals we just masked off. - boost::thread( signalProcessingThread ).detach(); + stdx::thread( signalProcessingThread ).detach(); #endif } diff --git a/src/mongo/util/signal_handlers_synchronous.cpp b/src/mongo/util/signal_handlers_synchronous.cpp index 534cadd8521..c49e35395f6 100644 --- a/src/mongo/util/signal_handlers_synchronous.cpp +++ b/src/mongo/util/signal_handlers_synchronous.cpp @@ -34,7 +34,6 @@ #include <boost/exception/diagnostic_information.hpp> #include <boost/exception/exception.hpp> -#include <boost/thread.hpp> #include <csignal> #include <exception> #include <iostream> @@ -46,6 +45,7 @@ #include "mongo/base/string_data.h" #include "mongo/logger/log_domain.h" #include "mongo/logger/logger.h" +#include "mongo/stdx/thread.h" #include "mongo/util/concurrency/thread_name.h" #include "mongo/util/debug_util.h" #include "mongo/util/debugger.h" |