From 4035cab6b974613af9eb06ac1a92cc39d6ba8e06 Mon Sep 17 00:00:00 2001 From: Andrew Morrow Date: Wed, 10 Jun 2015 19:01:38 -0400 Subject: SERVER-17307 Replace boost::shared_ptr and friends with std::shared_ptr --- src/mongo/util/concurrency/task.h | 2 +- src/mongo/util/embedded_builder.h | 5 ++--- src/mongo/util/net/listen.cpp | 9 ++++----- src/mongo/util/net/listen.h | 3 +-- src/mongo/util/net/message_port.cpp | 5 ++--- src/mongo/util/net/message_port.h | 5 ++--- src/mongo/util/net/message_server_port.cpp | 4 ++-- src/mongo/util/net/miniwebserver.cpp | 5 ++--- src/mongo/util/net/miniwebserver.h | 3 +-- src/mongo/util/net/sock_test.cpp | 5 ++--- src/mongo/util/options_parser/environment.cpp | 3 +-- src/mongo/util/options_parser/environment.h | 1 - src/mongo/util/options_parser/option_description.cpp | 5 ++--- src/mongo/util/options_parser/option_description.h | 3 +-- src/mongo/util/options_parser/option_section.cpp | 7 +++---- src/mongo/util/options_parser/option_section.h | 3 +-- src/mongo/util/options_parser/options_parser.cpp | 7 +++---- src/mongo/util/unowned_ptr.h | 4 ---- src/mongo/util/unowned_ptr_test.cpp | 8 ++++---- 19 files changed, 34 insertions(+), 53 deletions(-) (limited to 'src/mongo/util') diff --git a/src/mongo/util/concurrency/task.h b/src/mongo/util/concurrency/task.h index 2b1ea26a1ce..e3430a6f9b4 100644 --- a/src/mongo/util/concurrency/task.h +++ b/src/mongo/util/concurrency/task.h @@ -74,7 +74,7 @@ namespace mongo { virtual void doWork() { result = 1234; } Sample() : result(0) { } }; - boost::shared_ptr q( new Sample() ); + std::shared_ptr q( new Sample() ); fork(q); cout << q->result << std::endl; // could print 1234 or 0. } diff --git a/src/mongo/util/embedded_builder.h b/src/mongo/util/embedded_builder.h index 068d80200c2..3ef84f427e0 100644 --- a/src/mongo/util/embedded_builder.h +++ b/src/mongo/util/embedded_builder.h @@ -29,7 +29,6 @@ #pragma once -#include namespace mongo { @@ -86,7 +85,7 @@ namespace mongo { private: void addBuilder( const std::string &name ) { - boost::shared_ptr< BSONObjBuilder > newBuilder( new BSONObjBuilder( back()->subobjStart( name ) ) ); + std::shared_ptr< BSONObjBuilder > newBuilder( new BSONObjBuilder( back()->subobjStart( name ) ) ); _builders.push_back( std::make_pair( name, newBuilder.get() ) ); _builderStorage.push_back( newBuilder ); } @@ -99,7 +98,7 @@ namespace mongo { BSONObjBuilder *back() { return _builders.back().second; } std::vector< std::pair< std::string, BSONObjBuilder * > > _builders; - std::vector< boost::shared_ptr< BSONObjBuilder > > _builderStorage; + std::vector< std::shared_ptr< BSONObjBuilder > > _builderStorage; }; diff --git a/src/mongo/util/net/listen.cpp b/src/mongo/util/net/listen.cpp index 4cb97c9367e..1a7f0773588 100644 --- a/src/mongo/util/net/listen.cpp +++ b/src/mongo/util/net/listen.cpp @@ -34,7 +34,6 @@ #include "mongo/util/net/listen.h" -#include #include "mongo/config.h" #include "mongo/db/server_options.h" @@ -75,7 +74,7 @@ namespace mongo { - using boost::shared_ptr; + using std::shared_ptr; using std::endl; using std::string; using std::vector; @@ -339,7 +338,7 @@ namespace mongo { log() << "connection accepted from " << from.toString() << " #" << myConnectionNumber << " (" << conns << word << " now open)" << endl; } - boost::shared_ptr pnewSock( new Socket(s, from) ); + std::shared_ptr pnewSock( new Socket(s, from) ); #ifdef MONGO_CONFIG_SSL if (_ssl) { pnewSock->secureAccepted(_ssl); @@ -556,7 +555,7 @@ namespace mongo { log() << "connection accepted from " << from.toString() << " #" << myConnectionNumber << " (" << conns << word << " now open)" << endl; } - boost::shared_ptr pnewSock( new Socket(s, from) ); + std::shared_ptr pnewSock( new Socket(s, from) ); #ifdef MONGO_CONFIG_SSL if (_ssl) { pnewSock->secureAccepted(_ssl); @@ -578,7 +577,7 @@ namespace mongo { } } - void Listener::accepted(boost::shared_ptr psocket, long long connectionId ) { + void Listener::accepted(std::shared_ptr psocket, long long connectionId ) { MessagingPort* port = new MessagingPort(psocket); port->setConnectionId( connectionId ); acceptedMP( port ); diff --git a/src/mongo/util/net/listen.h b/src/mongo/util/net/listen.h index f2b336c3a7e..2db88ffb141 100644 --- a/src/mongo/util/net/listen.h +++ b/src/mongo/util/net/listen.h @@ -30,7 +30,6 @@ #pragma once #include -#include #include #include #include @@ -58,7 +57,7 @@ namespace mongo { void initAndListen(); // never returns unless error (start a thread) /* spawn a thread, etc., then return */ - virtual void accepted(boost::shared_ptr psocket, long long connectionId ); + virtual void accepted(std::shared_ptr psocket, long long connectionId ); virtual void acceptedMP(MessagingPort *mp); const int _port; diff --git a/src/mongo/util/net/message_port.cpp b/src/mongo/util/net/message_port.cpp index 3d7829d2300..be05fbd1aff 100644 --- a/src/mongo/util/net/message_port.cpp +++ b/src/mongo/util/net/message_port.cpp @@ -33,7 +33,6 @@ #include "mongo/util/net/message_port.h" -#include #include #include @@ -58,7 +57,7 @@ namespace mongo { - using boost::shared_ptr; + using std::shared_ptr; using std::string; // if you want trace output: @@ -154,7 +153,7 @@ namespace mongo { piggyBackData = 0; } - MessagingPort::MessagingPort( boost::shared_ptr sock ) + MessagingPort::MessagingPort( std::shared_ptr sock ) : psock( sock ), piggyBackData( 0 ) { ports.insert(this); } diff --git a/src/mongo/util/net/message_port.h b/src/mongo/util/net/message_port.h index 45f8eae4d62..161b30037af 100644 --- a/src/mongo/util/net/message_port.h +++ b/src/mongo/util/net/message_port.h @@ -30,7 +30,6 @@ #pragma once #include -#include #include #include "mongo/config.h" @@ -86,7 +85,7 @@ namespace mongo { MessagingPort(double so_timeout = 0, logger::LogSeverity logLevel = logger::LogSeverity::Log() ); - MessagingPort(boost::shared_ptr socket); + MessagingPort(std::shared_ptr socket); virtual ~MessagingPort(); @@ -122,7 +121,7 @@ namespace mongo { virtual SockAddr remoteAddr() const; virtual SockAddr localAddr() const; - boost::shared_ptr psock; + std::shared_ptr psock; void send( const char * data , int len, const char *context ) { psock->send( data, len, context ); diff --git a/src/mongo/util/net/message_server_port.cpp b/src/mongo/util/net/message_server_port.cpp index e8df178e2af..f6e5f95a44e 100644 --- a/src/mongo/util/net/message_server_port.cpp +++ b/src/mongo/util/net/message_server_port.cpp @@ -73,7 +73,7 @@ namespace { MONGO_DISALLOW_COPYING(MessagingPortWithHandler); public: - MessagingPortWithHandler(const boost::shared_ptr& socket, + MessagingPortWithHandler(const std::shared_ptr& socket, MessageHandler* handler, long long connectionId) : MessagingPort(socket), _handler(handler) { @@ -102,7 +102,7 @@ namespace { Listener( "" , opts.ipList, opts.port ), _handler(handler) { } - virtual void accepted(boost::shared_ptr psocket, long long connectionId ) { + virtual void accepted(std::shared_ptr psocket, long long connectionId ) { ScopeGuard sleepAfterClosingPort = MakeGuard(sleepmillis, 2); std::unique_ptr portWithHandler( new MessagingPortWithHandler(psocket, _handler, connectionId)); diff --git a/src/mongo/util/net/miniwebserver.cpp b/src/mongo/util/net/miniwebserver.cpp index 2dbf68b6d6f..888ca70e4de 100644 --- a/src/mongo/util/net/miniwebserver.cpp +++ b/src/mongo/util/net/miniwebserver.cpp @@ -33,7 +33,6 @@ #include "mongo/util/net/miniwebserver.h" -#include #include #include "mongo/config.h" @@ -42,7 +41,7 @@ namespace mongo { - using boost::shared_ptr; + using std::shared_ptr; using std::endl; using std::stringstream; using std::vector; @@ -132,7 +131,7 @@ namespace mongo { return false; } - void MiniWebServer::accepted(boost::shared_ptr psock, long long connectionId ) { + void MiniWebServer::accepted(std::shared_ptr psock, long long connectionId ) { char buf[4096]; int len = 0; try { diff --git a/src/mongo/util/net/miniwebserver.h b/src/mongo/util/net/miniwebserver.h index 6ae82f90966..d0eb06f445a 100644 --- a/src/mongo/util/net/miniwebserver.h +++ b/src/mongo/util/net/miniwebserver.h @@ -31,7 +31,6 @@ #include "mongo/platform/basic.h" -#include #include "mongo/db/jsobj.h" #include "mongo/util/net/listen.h" @@ -68,7 +67,7 @@ namespace mongo { static std::string urlDecode(const std::string& s) {return urlDecode(s.c_str());} private: - void accepted(boost::shared_ptr psocket, long long connectionId ); + void accepted(std::shared_ptr psocket, long long connectionId ); static bool fullReceive( const char *buf ); }; diff --git a/src/mongo/util/net/sock_test.cpp b/src/mongo/util/net/sock_test.cpp index 3b6a6a07638..dbc42903915 100644 --- a/src/mongo/util/net/sock_test.cpp +++ b/src/mongo/util/net/sock_test.cpp @@ -30,7 +30,6 @@ #include "mongo/util/net/sock.h" -#include #include #ifndef _WIN32 @@ -47,9 +46,9 @@ namespace { using namespace mongo; - using boost::shared_ptr; + using std::shared_ptr; - typedef boost::shared_ptr SocketPtr; + typedef std::shared_ptr SocketPtr; typedef std::pair SocketPair; // On UNIX, make a connected pair of PF_LOCAL (aka PF_UNIX) sockets via the native 'socketpair' diff --git a/src/mongo/util/options_parser/environment.cpp b/src/mongo/util/options_parser/environment.cpp index 432c8735e1d..2aa768f6f07 100644 --- a/src/mongo/util/options_parser/environment.cpp +++ b/src/mongo/util/options_parser/environment.cpp @@ -27,7 +27,6 @@ #include "mongo/util/options_parser/environment.h" -#include #include #include "mongo/bson/util/builder.h" @@ -37,7 +36,7 @@ namespace mongo { namespace optionenvironment { - using boost::shared_ptr; + using std::shared_ptr; using std::string; using std::type_info; diff --git a/src/mongo/util/options_parser/environment.h b/src/mongo/util/options_parser/environment.h index 8c44eb661d1..507ee4f7592 100644 --- a/src/mongo/util/options_parser/environment.h +++ b/src/mongo/util/options_parser/environment.h @@ -27,7 +27,6 @@ #pragma once -#include #include #include diff --git a/src/mongo/util/options_parser/option_description.cpp b/src/mongo/util/options_parser/option_description.cpp index c903a3ddce0..ebef43be3cf 100644 --- a/src/mongo/util/options_parser/option_description.cpp +++ b/src/mongo/util/options_parser/option_description.cpp @@ -28,14 +28,13 @@ #include "mongo/util/options_parser/option_description.h" #include -#include #include "mongo/util/assert_util.h" namespace mongo { namespace optionenvironment { - using boost::shared_ptr; + using std::shared_ptr; namespace { /** @@ -284,7 +283,7 @@ namespace optionenvironment { } OptionDescription& OptionDescription::addConstraint(Constraint* c) { - _constraints.push_back(boost::shared_ptr(c)); + _constraints.push_back(std::shared_ptr(c)); return *this; } diff --git a/src/mongo/util/options_parser/option_description.h b/src/mongo/util/options_parser/option_description.h index 5bfe83c3a30..b126df402f6 100644 --- a/src/mongo/util/options_parser/option_description.h +++ b/src/mongo/util/options_parser/option_description.h @@ -27,7 +27,6 @@ #pragma once -#include #include #include "mongo/base/status.h" @@ -225,7 +224,7 @@ namespace optionenvironment { // these classes. Note that the Environment (the storage for results of option parsing) has // to know about the constraints for all the options, which is another factor to consider // when thinking about ownership. - std::vector > _constraints; // Constraints that must be met + std::vector > _constraints; // Constraints that must be met // for this option to be valid // Deprecated dotted names - aliases for '_dottedName'. diff --git a/src/mongo/util/options_parser/option_section.cpp b/src/mongo/util/options_parser/option_section.cpp index 5d3646554ee..c996f615ba4 100644 --- a/src/mongo/util/options_parser/option_section.cpp +++ b/src/mongo/util/options_parser/option_section.cpp @@ -28,7 +28,6 @@ #include "mongo/util/options_parser/option_section.h" #include -#include #include #include @@ -39,7 +38,7 @@ namespace mongo { namespace optionenvironment { - using boost::shared_ptr; + using std::shared_ptr; // Registration interface @@ -544,11 +543,11 @@ namespace optionenvironment { } Status OptionSection::getConstraints( - std::vector >* constraints) const { + std::vector >* constraints) const { std::list::const_iterator oditerator; for (oditerator = _options.begin(); oditerator != _options.end(); oditerator++) { - std::vector >::const_iterator citerator; + std::vector >::const_iterator citerator; for (citerator = oditerator->_constraints.begin(); citerator != oditerator->_constraints.end(); citerator++) { constraints->push_back(*citerator); diff --git a/src/mongo/util/options_parser/option_section.h b/src/mongo/util/options_parser/option_section.h index 572e2b60e0d..1cfe5668170 100644 --- a/src/mongo/util/options_parser/option_section.h +++ b/src/mongo/util/options_parser/option_section.h @@ -29,7 +29,6 @@ #include "mongo/util/options_parser/option_description.h" #include -#include #include #include "mongo/base/status.h" @@ -155,7 +154,7 @@ namespace optionenvironment { * Populates the given vector with all the constraints for all options in this section and * sub sections. */ - Status getConstraints(std::vector >* constraints) const; + Status getConstraints(std::vector >* constraints) const; std::string positionalHelpString(const std::string& execName) const; std::string helpString() const; diff --git a/src/mongo/util/options_parser/options_parser.cpp b/src/mongo/util/options_parser/options_parser.cpp index e4d4817f546..eebd7d83e2c 100644 --- a/src/mongo/util/options_parser/options_parser.cpp +++ b/src/mongo/util/options_parser/options_parser.cpp @@ -30,7 +30,6 @@ #include "mongo/util/options_parser/options_parser.h" #include -#include #include #include #include @@ -53,7 +52,7 @@ namespace mongo { namespace optionenvironment { using namespace std; - using boost::shared_ptr; + using std::shared_ptr; namespace po = boost::program_options; @@ -606,14 +605,14 @@ namespace optionenvironment { * they run when the environment gets validated. */ Status addConstraints(const OptionSection& options, Environment* dest) { - std::vector > constraints_vector; + std::vector > constraints_vector; Status ret = options.getConstraints(&constraints_vector); if (!ret.isOK()) { return ret; } - std::vector >::const_iterator citerator; + std::vector >::const_iterator citerator; for (citerator = constraints_vector.begin(); citerator != constraints_vector.end(); citerator++) { dest->addConstraint(citerator->get()); diff --git a/src/mongo/util/unowned_ptr.h b/src/mongo/util/unowned_ptr.h index 7bc66dda59b..b2053d13da3 100644 --- a/src/mongo/util/unowned_ptr.h +++ b/src/mongo/util/unowned_ptr.h @@ -28,7 +28,6 @@ #pragma once -#include #include #include #include @@ -71,9 +70,6 @@ namespace mongo { template> unowned_ptr(const std::shared_ptr& p) : _p(p.get()) {} - template> - unowned_ptr(const boost::shared_ptr& p) : _p(p.get()) {} - // // Modifiers // diff --git a/src/mongo/util/unowned_ptr_test.cpp b/src/mongo/util/unowned_ptr_test.cpp index 058480e3936..5ad5366b7dc 100644 --- a/src/mongo/util/unowned_ptr_test.cpp +++ b/src/mongo/util/unowned_ptr_test.cpp @@ -40,7 +40,7 @@ namespace mongo { std::unique_ptr p1(new int(1)); std::shared_ptr p2(new int(2)); std::unique_ptr p3(new int(3)); - boost::shared_ptr p4(new int(4)); + std::shared_ptr p4(new int(4)); ASSERT_EQUALS(aNullPtr, unowned_ptr()); ASSERT_EQUALS(aNullPtr, unowned_ptr({})); @@ -53,7 +53,7 @@ namespace mongo { //const std::unique_ptr cp1(new int(11)); - boost::shared_ptr cp2(new int(12)); + std::shared_ptr cp2(new int(12)); ASSERT_EQUALS(aNullPtr, unowned_ptr()); ASSERT_EQUALS(aNullPtr, unowned_ptr({})); @@ -81,7 +81,7 @@ namespace mongo { std::unique_ptr p1(new int(1)); std::shared_ptr p2(new int(2)); std::unique_ptr p3(new int(3)); - boost::shared_ptr p4(new int(4)); + std::shared_ptr p4(new int(4)); ASSERT_EQUALS(aNullPtr, (unowned_ptr() = {})); ASSERT_EQUALS(aNullPtr, (unowned_ptr() = nullptr)); @@ -93,7 +93,7 @@ namespace mongo { //const std::unique_ptr cp1(new int(11)); - boost::shared_ptr cp2(new int(12)); + std::shared_ptr cp2(new int(12)); ASSERT_EQUALS(aNullPtr, (unowned_ptr() = {})); ASSERT_EQUALS(aNullPtr, (unowned_ptr() = nullptr)); -- cgit v1.2.1