summaryrefslogtreecommitdiff
path: root/src/mongo/util
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2015-06-10 19:01:38 -0400
committerAndrew Morrow <acm@mongodb.com>2015-06-10 22:38:00 -0400
commit4035cab6b974613af9eb06ac1a92cc39d6ba8e06 (patch)
tree15c606e4514037d563fad28de9c091de3d9e473e /src/mongo/util
parent1360f243ee7fa662c0ded25a9bc479aa47388446 (diff)
downloadmongo-4035cab6b974613af9eb06ac1a92cc39d6ba8e06.tar.gz
SERVER-17307 Replace boost::shared_ptr and friends with std::shared_ptr
Diffstat (limited to 'src/mongo/util')
-rw-r--r--src/mongo/util/concurrency/task.h2
-rw-r--r--src/mongo/util/embedded_builder.h5
-rw-r--r--src/mongo/util/net/listen.cpp9
-rw-r--r--src/mongo/util/net/listen.h3
-rw-r--r--src/mongo/util/net/message_port.cpp5
-rw-r--r--src/mongo/util/net/message_port.h5
-rw-r--r--src/mongo/util/net/message_server_port.cpp4
-rw-r--r--src/mongo/util/net/miniwebserver.cpp5
-rw-r--r--src/mongo/util/net/miniwebserver.h3
-rw-r--r--src/mongo/util/net/sock_test.cpp5
-rw-r--r--src/mongo/util/options_parser/environment.cpp3
-rw-r--r--src/mongo/util/options_parser/environment.h1
-rw-r--r--src/mongo/util/options_parser/option_description.cpp5
-rw-r--r--src/mongo/util/options_parser/option_description.h3
-rw-r--r--src/mongo/util/options_parser/option_section.cpp7
-rw-r--r--src/mongo/util/options_parser/option_section.h3
-rw-r--r--src/mongo/util/options_parser/options_parser.cpp7
-rw-r--r--src/mongo/util/unowned_ptr.h4
-rw-r--r--src/mongo/util/unowned_ptr_test.cpp8
19 files changed, 34 insertions, 53 deletions
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<Sample> q( new Sample() );
+ std::shared_ptr<Sample> 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 <boost/shared_ptr.hpp>
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 <boost/shared_ptr.hpp>
#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<Socket> pnewSock( new Socket(s, from) );
+ std::shared_ptr<Socket> 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<Socket> pnewSock( new Socket(s, from) );
+ std::shared_ptr<Socket> 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<Socket> psocket, long long connectionId ) {
+ void Listener::accepted(std::shared_ptr<Socket> 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 <boost/noncopyable.hpp>
-#include <boost/shared_ptr.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
#include <set>
@@ -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<Socket> psocket, long long connectionId );
+ virtual void accepted(std::shared_ptr<Socket> 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 <boost/shared_ptr.hpp>
#include <fcntl.h>
#include <time.h>
@@ -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<Socket> sock )
+ MessagingPort::MessagingPort( std::shared_ptr<Socket> 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 <boost/noncopyable.hpp>
-#include <boost/shared_ptr.hpp>
#include <vector>
#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> socket);
+ MessagingPort(std::shared_ptr<Socket> socket);
virtual ~MessagingPort();
@@ -122,7 +121,7 @@ namespace mongo {
virtual SockAddr remoteAddr() const;
virtual SockAddr localAddr() const;
- boost::shared_ptr<Socket> psock;
+ std::shared_ptr<Socket> 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>& socket,
+ MessagingPortWithHandler(const std::shared_ptr<Socket>& 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<Socket> psocket, long long connectionId ) {
+ virtual void accepted(std::shared_ptr<Socket> psocket, long long connectionId ) {
ScopeGuard sleepAfterClosingPort = MakeGuard(sleepmillis, 2);
std::unique_ptr<MessagingPortWithHandler> 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 <boost/shared_ptr.hpp>
#include <pcrecpp.h>
#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<Socket> psock, long long connectionId ) {
+ void MiniWebServer::accepted(std::shared_ptr<Socket> 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 <boost/shared_ptr.hpp>
#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<Socket> psocket, long long connectionId );
+ void accepted(std::shared_ptr<Socket> 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 <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
#ifndef _WIN32
@@ -47,9 +46,9 @@
namespace {
using namespace mongo;
- using boost::shared_ptr;
+ using std::shared_ptr;
- typedef boost::shared_ptr<Socket> SocketPtr;
+ typedef std::shared_ptr<Socket> SocketPtr;
typedef std::pair<SocketPtr, SocketPtr> 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 <boost/shared_ptr.hpp>
#include <iostream>
#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 <boost/shared_ptr.hpp>
#include <map>
#include <vector>
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 <algorithm>
-#include <boost/shared_ptr.hpp>
#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<Constraint>(c));
+ _constraints.push_back(std::shared_ptr<Constraint>(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 <boost/shared_ptr.hpp>
#include <vector>
#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<boost::shared_ptr<Constraint> > _constraints; // Constraints that must be met
+ std::vector<std::shared_ptr<Constraint> > _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 <algorithm>
-#include <boost/shared_ptr.hpp>
#include <iostream>
#include <sstream>
@@ -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<boost::shared_ptr<Constraint > >* constraints) const {
+ std::vector<std::shared_ptr<Constraint > >* constraints) const {
std::list<OptionDescription>::const_iterator oditerator;
for (oditerator = _options.begin(); oditerator != _options.end(); oditerator++) {
- std::vector<boost::shared_ptr<Constraint> >::const_iterator citerator;
+ std::vector<std::shared_ptr<Constraint> >::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 <boost/program_options.hpp>
-#include <boost/shared_ptr.hpp>
#include <list>
#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<boost::shared_ptr<Constraint > >* constraints) const;
+ Status getConstraints(std::vector<std::shared_ptr<Constraint > >* 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 <boost/program_options.hpp>
-#include <boost/shared_ptr.hpp>
#include <algorithm>
#include <cerrno>
#include <fstream>
@@ -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<boost::shared_ptr<Constraint> > constraints_vector;
+ std::vector<std::shared_ptr<Constraint> > constraints_vector;
Status ret = options.getConstraints(&constraints_vector);
if (!ret.isOK()) {
return ret;
}
- std::vector<boost::shared_ptr<Constraint> >::const_iterator citerator;
+ std::vector<std::shared_ptr<Constraint> >::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 <boost/shared_ptr.hpp>
#include <boost/static_assert.hpp>
#include <memory>
#include <type_traits>
@@ -71,9 +70,6 @@ namespace mongo {
template<typename U, typename = IfConvertibleFrom<U>>
unowned_ptr(const std::shared_ptr<U>& p) : _p(p.get()) {}
- template<typename U, typename = IfConvertibleFrom<U>>
- unowned_ptr(const boost::shared_ptr<U>& 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<int> p1(new int(1));
std::shared_ptr<int> p2(new int(2));
std::unique_ptr<int> p3(new int(3));
- boost::shared_ptr<int> p4(new int(4));
+ std::shared_ptr<int> p4(new int(4));
ASSERT_EQUALS(aNullPtr, unowned_ptr<int>());
ASSERT_EQUALS(aNullPtr, unowned_ptr<int>({}));
@@ -53,7 +53,7 @@ namespace mongo {
//const
std::unique_ptr<const int> cp1(new int(11));
- boost::shared_ptr<const int> cp2(new int(12));
+ std::shared_ptr<const int> cp2(new int(12));
ASSERT_EQUALS(aNullPtr, unowned_ptr<const int>());
ASSERT_EQUALS(aNullPtr, unowned_ptr<const int>({}));
@@ -81,7 +81,7 @@ namespace mongo {
std::unique_ptr<int> p1(new int(1));
std::shared_ptr<int> p2(new int(2));
std::unique_ptr<int> p3(new int(3));
- boost::shared_ptr<int> p4(new int(4));
+ std::shared_ptr<int> p4(new int(4));
ASSERT_EQUALS(aNullPtr, (unowned_ptr<int>() = {}));
ASSERT_EQUALS(aNullPtr, (unowned_ptr<int>() = nullptr));
@@ -93,7 +93,7 @@ namespace mongo {
//const
std::unique_ptr<const int> cp1(new int(11));
- boost::shared_ptr<const int> cp2(new int(12));
+ std::shared_ptr<const int> cp2(new int(12));
ASSERT_EQUALS(aNullPtr, (unowned_ptr<const int>() = {}));
ASSERT_EQUALS(aNullPtr, (unowned_ptr<const int>() = nullptr));