diff options
author | Andrew Morrow <acm@mongodb.com> | 2015-06-15 14:54:26 -0400 |
---|---|---|
committer | Andrew Morrow <acm@mongodb.com> | 2015-06-16 16:31:58 -0400 |
commit | 22dd61cfe60e05b13f9bb92aee3cb4660392435b (patch) | |
tree | 2046de28fe9e566dd9b1c023c9feec88385e480d /src | |
parent | be88e42ef819aeb76b8625e646adf67626844c25 (diff) | |
download | mongo-22dd61cfe60e05b13f9bb92aee3cb4660392435b.tar.gz |
SERVER-18991 Replace all usages of boost::noncopyable with MONGO_DISALLOW_COPYING
Diffstat (limited to 'src')
36 files changed, 167 insertions, 125 deletions
diff --git a/src/mongo/bson/bsonmisc.h b/src/mongo/bson/bsonmisc.h index 0c0ea6cdb80..3c9e5259161 100644 --- a/src/mongo/bson/bsonmisc.h +++ b/src/mongo/bson/bsonmisc.h @@ -204,7 +204,8 @@ namespace mongo { // definitions in bsonobjbuilder.h b/c of incomplete types // Utility class to implement BSON( key << val ) as described above. - class BSONObjBuilderValueStream : public boost::noncopyable { + class BSONObjBuilderValueStream { + MONGO_DISALLOW_COPYING(BSONObjBuilderValueStream); public: friend class Labeler; BSONObjBuilderValueStream( BSONObjBuilder * builder ); diff --git a/src/mongo/bson/bsonobjbuilder.h b/src/mongo/bson/bsonobjbuilder.h index a533284b120..4ca65d75693 100644 --- a/src/mongo/bson/bsonobjbuilder.h +++ b/src/mongo/bson/bsonobjbuilder.h @@ -34,7 +34,6 @@ #pragma once -#include <boost/noncopyable.hpp> #include <boost/static_assert.hpp> #include <map> #include <cmath> @@ -57,7 +56,8 @@ namespace mongo { /** Utility for creating a BSONObj. See also the BSON() and BSON_ARRAY() macros. */ - class BSONObjBuilder : boost::noncopyable { + class BSONObjBuilder { + MONGO_DISALLOW_COPYING(BSONObjBuilder); public: /** @param initsize this is just a hint as to the final size of the object */ BSONObjBuilder(int initsize=512) @@ -716,7 +716,8 @@ namespace mongo { static bool numStrsReady; // for static init safety }; - class BSONArrayBuilder : boost::noncopyable { + class BSONArrayBuilder { + MONGO_DISALLOW_COPYING(BSONArrayBuilder); public: BSONArrayBuilder() : _i(0), _b() {} BSONArrayBuilder( BufBuilder &_b ) : _i(0), _b(_b) {} diff --git a/src/mongo/client/connpool.h b/src/mongo/client/connpool.h index 1c6728d3352..fd0204dd46a 100644 --- a/src/mongo/client/connpool.h +++ b/src/mongo/client/connpool.h @@ -29,7 +29,6 @@ #pragma once -#include <boost/noncopyable.hpp> #include <stack> #include "mongo/client/dbclientinterface.h" @@ -266,7 +265,8 @@ namespace mongo { }; - class AScopedConnection : boost::noncopyable { + class AScopedConnection { + MONGO_DISALLOW_COPYING(AScopedConnection); public: AScopedConnection() { _numConnections.fetchAndAdd(1); } virtual ~AScopedConnection() { _numConnections.fetchAndAdd(-1); } diff --git a/src/mongo/client/dbclientcursor.h b/src/mongo/client/dbclientcursor.h index 4dca614591f..6f125063b60 100644 --- a/src/mongo/client/dbclientcursor.h +++ b/src/mongo/client/dbclientcursor.h @@ -29,7 +29,6 @@ #pragma once -#include <boost/noncopyable.hpp> #include <stack> #include "mongo/client/dbclientinterface.h" @@ -44,7 +43,8 @@ namespace mongo { /** for mock purposes only -- do not create variants of DBClientCursor, nor hang code here @see DBClientMockCursor */ - class DBClientCursorInterface : boost::noncopyable { + class DBClientCursorInterface { + MONGO_DISALLOW_COPYING(DBClientCursorInterface); public: virtual ~DBClientCursorInterface() {} virtual bool more() = 0; @@ -204,7 +204,8 @@ namespace mongo { void initLazy( bool isRetry = false ); bool initLazyFinish( bool& retry ); - class Batch : boost::noncopyable { + class Batch { + MONGO_DISALLOW_COPYING(Batch); friend class DBClientCursor; std::unique_ptr<Message> m; int nReturned; diff --git a/src/mongo/client/dbclientinterface.h b/src/mongo/client/dbclientinterface.h index a41d6cac357..853cae2d898 100644 --- a/src/mongo/client/dbclientinterface.h +++ b/src/mongo/client/dbclientinterface.h @@ -28,8 +28,6 @@ #pragma once -#include <boost/noncopyable.hpp> - #include "mongo/base/string_data.h" #include "mongo/client/connection_string.h" #include "mongo/client/read_preference.h" @@ -372,7 +370,8 @@ namespace mongo { /** The interface that any db connection should implement */ - class DBClientInterface : boost::noncopyable { + class DBClientInterface { + MONGO_DISALLOW_COPYING(DBClientInterface); public: virtual std::unique_ptr<DBClientCursor> query(const std::string &ns, Query query, int nToReturn = 0, int nToSkip = 0, const BSONObj *fieldsToReturn = 0, int queryOptions = 0 , int batchSize = 0 ) = 0; @@ -409,6 +408,9 @@ namespace mongo { /** don't use this - called automatically by DBClientCursor for you */ virtual std::unique_ptr<DBClientCursor> getMore( const std::string &ns, long long cursorId, int nToReturn = 0, int options = 0 ) = 0; + + protected: + DBClientInterface() = default; }; /** diff --git a/src/mongo/db/clientcursor.h b/src/mongo/db/clientcursor.h index 4e81a39d7ba..d2482ffbfa9 100644 --- a/src/mongo/db/clientcursor.h +++ b/src/mongo/db/clientcursor.h @@ -28,8 +28,6 @@ #pragma once -#include <boost/noncopyable.hpp> - #include "mongo/db/jsobj.h" #include "mongo/db/query/plan_executor.h" #include "mongo/db/record_id.h" @@ -50,7 +48,8 @@ namespace mongo { * ClientCursor is a wrapper that represents a cursorid from our database application's * perspective. */ - class ClientCursor : private boost::noncopyable { + class ClientCursor { + MONGO_DISALLOW_COPYING(ClientCursor); public: /** * This ClientCursor constructor creates a cursorid that can be used with getMore and diff --git a/src/mongo/db/commands/mr.h b/src/mongo/db/commands/mr.h index b36e36b29b9..083165ebe27 100644 --- a/src/mongo/db/commands/mr.h +++ b/src/mongo/db/commands/mr.h @@ -30,7 +30,6 @@ #pragma once -#include <boost/noncopyable.hpp> #include <string> #include <vector> @@ -55,15 +54,19 @@ namespace mongo { // ------------ function interfaces ----------- - class Mapper : boost::noncopyable { + class Mapper { + MONGO_DISALLOW_COPYING(Mapper); public: virtual ~Mapper() {} virtual void init( State * state ) = 0; virtual void map( const BSONObj& o ) = 0; + protected: + Mapper() = default; }; - class Finalizer : boost::noncopyable { + class Finalizer { + MONGO_DISALLOW_COPYING(Finalizer); public: virtual ~Finalizer() {} virtual void init( State * state ) = 0; @@ -72,9 +75,13 @@ namespace mongo { * this takes a tuple and returns a tuple */ virtual BSONObj finalize( const BSONObj& tuple ) = 0; + + protected: + Finalizer() = default; }; - class Reducer : boost::noncopyable { + class Reducer { + MONGO_DISALLOW_COPYING(Reducer); public: Reducer() : numReduces(0) {} virtual ~Reducer() {} @@ -93,7 +100,8 @@ namespace mongo { * used as a holder for Scope and ScriptingFunction * visitor like pattern as Scope is gotten from first access */ - class JSFunction : boost::noncopyable { + class JSFunction { + MONGO_DISALLOW_COPYING(JSFunction); public: /** * @param type (map|reduce|finalize) diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h index 080739204f4..e8467f507b8 100644 --- a/src/mongo/db/curop.h +++ b/src/mongo/db/curop.h @@ -31,8 +31,6 @@ #pragma once -#include <boost/noncopyable.hpp> - #include "mongo/base/disallow_copying.h" #include "mongo/db/operation_context.h" #include "mongo/db/server_options.h" diff --git a/src/mongo/db/dbhelpers.h b/src/mongo/db/dbhelpers.h index a5e173773ca..a0ca0f0bc3d 100644 --- a/src/mongo/db/dbhelpers.h +++ b/src/mongo/db/dbhelpers.h @@ -209,7 +209,8 @@ namespace mongo { /** * for saving deleted bson objects to a flat file */ - class RemoveSaver : public boost::noncopyable { + class RemoveSaver { + MONGO_DISALLOW_COPYING(RemoveSaver); public: RemoveSaver(const std::string& type, const std::string& ns, const std::string& why); ~RemoveSaver(); diff --git a/src/mongo/db/geo/r2_region_coverer.cpp b/src/mongo/db/geo/r2_region_coverer.cpp index c5ee989f85e..b43db9665ad 100644 --- a/src/mongo/db/geo/r2_region_coverer.cpp +++ b/src/mongo/db/geo/r2_region_coverer.cpp @@ -36,21 +36,9 @@ namespace mongo { - using std::less; - // Definition int const R2RegionCoverer::kDefaultMaxCells = 8; - // We define our own own comparison function on QueueEntries in order to - // make the results deterministic. Using the default less<QueueEntry>, - // entries of equal priority would be sorted according to the memory address - // of the candidate. - struct R2RegionCoverer::CompareQueueEntries : public less<QueueEntry> { - bool operator()(QueueEntry const& x, QueueEntry const& y) { - return x.first < y.first; - } - }; - // Doesn't take ownership of "hashConverter". The caller should guarantee its life cycle // is longer than this coverer. R2RegionCoverer::R2RegionCoverer( GeoHashConverter* hashConverter ) : diff --git a/src/mongo/db/geo/r2_region_coverer.h b/src/mongo/db/geo/r2_region_coverer.h index ddfda208094..db0aa69c8d9 100644 --- a/src/mongo/db/geo/r2_region_coverer.h +++ b/src/mongo/db/geo/r2_region_coverer.h @@ -28,7 +28,6 @@ #pragma once -#include <boost/noncopyable.hpp> #include <queue> #include "mongo/db/geo/hash.h" @@ -38,11 +37,14 @@ namespace mongo { class R2Region; - class R2RegionCoverer : boost::noncopyable { + class R2RegionCoverer { + MONGO_DISALLOW_COPYING(R2RegionCoverer); + // By default, the covering uses at most 8 cells at any level. static const int kDefaultMaxCells; // = 8; public: + R2RegionCoverer() = default; R2RegionCoverer(GeoHashConverter* hashConverter); ~R2RegionCoverer(); @@ -104,8 +106,18 @@ namespace mongo { R2Region const* _region; // We keep the candidates that may intersect with this region in a priority queue. - struct CompareQueueEntries; typedef std::pair<int, Candidate*> QueueEntry; + + // We define our own own comparison function on QueueEntries in order to + // make the results deterministic. Using the default less<QueueEntry>, + // entries of equal priority would be sorted according to the memory address + // of the candidate. + struct CompareQueueEntries { + bool operator()(QueueEntry const& x, QueueEntry const& y) const { + return x.first < y.first; + } + }; + typedef std::priority_queue<QueueEntry, std::vector<QueueEntry>, CompareQueueEntries> CandidateQueue; std::unique_ptr<CandidateQueue> _candidateQueue; // Priority queue owns candidate pointers. @@ -114,8 +126,11 @@ namespace mongo { // An R2CellUnion is a region consisting of cells of various sizes. - class R2CellUnion : boost::noncopyable { + class R2CellUnion { + MONGO_DISALLOW_COPYING(R2CellUnion); public: + R2CellUnion() = default; + void init(const std::vector<GeoHash>& cellIds); bool contains(const GeoHash cellId) const; std::string toString() const; diff --git a/src/mongo/db/hasher.h b/src/mongo/db/hasher.h index 98d6a42ee03..e5bbb39d116 100644 --- a/src/mongo/db/hasher.h +++ b/src/mongo/db/hasher.h @@ -36,8 +36,6 @@ #include "mongo/platform/basic.h" -#include <boost/noncopyable.hpp> - #include "mongo/bson/bsonelement.h" #include "mongo/util/md5.hpp" @@ -46,7 +44,8 @@ namespace mongo { typedef int HashSeed; typedef unsigned char HashDigest[16]; - class Hasher : private boost::noncopyable { + class Hasher { + MONGO_DISALLOW_COPYING(Hasher); public: explicit Hasher( HashSeed seed ); @@ -64,7 +63,8 @@ namespace mongo { HashSeed _seed; }; - class HasherFactory : private boost::noncopyable { + class HasherFactory { + MONGO_DISALLOW_COPYING(HasherFactory); public: /* Eventually this may be a more sophisticated factory * for creating other hashers, but for now use MD5. @@ -77,7 +77,8 @@ namespace mongo { HasherFactory(); }; - class BSONElementHasher : private boost::noncopyable { + class BSONElementHasher { + MONGO_DISALLOW_COPYING(BSONElementHasher); public: /* The hash function we use can be given a seed, to effectively randomize it diff --git a/src/mongo/db/pipeline/document.h b/src/mongo/db/pipeline/document.h index 10d03ae8d2d..491b9c050d3 100644 --- a/src/mongo/db/pipeline/document.h +++ b/src/mongo/db/pipeline/document.h @@ -32,7 +32,6 @@ #include <boost/functional/hash.hpp> #include <boost/intrusive_ptr.hpp> -#include <boost/noncopyable.hpp> #include "mongo/bson/util/builder.h" @@ -278,7 +277,8 @@ namespace mongo { * shallow-clone its storage on write (COW) if it is shared with any other * Documents. */ - class MutableDocument : boost::noncopyable { + class MutableDocument { + MONGO_DISALLOW_COPYING(MutableDocument); public: /** Create a new empty Document. diff --git a/src/mongo/db/pipeline/document_internal.h b/src/mongo/db/pipeline/document_internal.h index 13d76be908e..93188ffb6f3 100644 --- a/src/mongo/db/pipeline/document_internal.h +++ b/src/mongo/db/pipeline/document_internal.h @@ -31,7 +31,6 @@ #include <third_party/murmurhash3/MurmurHash3.h> #include <boost/intrusive_ptr.hpp> -#include <boost/noncopyable.hpp> #include "mongo/util/intrusive_counter.h" #include "mongo/db/pipeline/value.h" @@ -65,7 +64,8 @@ namespace mongo { /** This is how values are stored in the DocumentStorage buffer * Internal class. Consumers shouldn't care about this. */ - class ValueElement : boost::noncopyable { + class ValueElement { + MONGO_DISALLOW_COPYING(ValueElement); public: Value val; Position nextCollision; // Position of next field with same hashBucket diff --git a/src/mongo/db/storage/mmap_v1/file_allocator.h b/src/mongo/db/storage/mmap_v1/file_allocator.h index aabe2a368bf..cb987b21618 100644 --- a/src/mongo/db/storage/mmap_v1/file_allocator.h +++ b/src/mongo/db/storage/mmap_v1/file_allocator.h @@ -31,7 +31,6 @@ #include <list> #include <boost/filesystem/path.hpp> -#include <boost/noncopyable.hpp> #include <boost/thread/condition.hpp> #include "mongo/util/concurrency/mutex.h" @@ -43,7 +42,8 @@ namespace mongo { * requested asynchronously or synchronously. * singleton */ - class FileAllocator : boost::noncopyable { + class FileAllocator { + MONGO_DISALLOW_COPYING(FileAllocator); /* * The public functions may not be called concurrently. The allocation * functions may be called multiple times per file, but only the first diff --git a/src/mongo/scripting/bson_template_evaluator.h b/src/mongo/scripting/bson_template_evaluator.h index 67c3c5bf7d0..24504803400 100644 --- a/src/mongo/scripting/bson_template_evaluator.h +++ b/src/mongo/scripting/bson_template_evaluator.h @@ -46,8 +46,6 @@ #include <map> #include <string> -#include <boost/noncopyable.hpp> - #include "mongo/db/jsobj.h" #include "mongo/stdx/functional.h" #include "mongo/platform/random.h" @@ -74,7 +72,8 @@ namespace mongo { * method. * */ - class BsonTemplateEvaluator : private boost::noncopyable { + class BsonTemplateEvaluator { + MONGO_DISALLOW_COPYING(BsonTemplateEvaluator); public: /* Status of template evaluation. Logically the the status are "success", "bad operator" * and "operation evaluation error." */ diff --git a/src/mongo/shell/bench.cpp b/src/mongo/shell/bench.cpp index bf5cc2c19f7..07171e0c834 100644 --- a/src/mongo/shell/bench.cpp +++ b/src/mongo/shell/bench.cpp @@ -36,7 +36,6 @@ #include <pcrecpp.h> -#include <boost/noncopyable.hpp> #include <boost/thread/thread.hpp> #include <iostream> @@ -719,7 +718,8 @@ namespace mongo { } namespace { - class BenchRunWorkerStateGuard : private boost::noncopyable { + class BenchRunWorkerStateGuard { + MONGO_DISALLOW_COPYING(BenchRunWorkerStateGuard); public: explicit BenchRunWorkerStateGuard( BenchRunState *brState ) : _brState( brState ) { _brState->onWorkerStarted(); diff --git a/src/mongo/shell/bench.h b/src/mongo/shell/bench.h index f8242bfec69..efd40ffa586 100644 --- a/src/mongo/shell/bench.h +++ b/src/mongo/shell/bench.h @@ -31,7 +31,6 @@ #include <string> #include <boost/thread/condition.hpp> -#include <boost/noncopyable.hpp> #include <boost/thread/mutex.hpp> #include "mongo/client/dbclientinterface.h" @@ -48,7 +47,8 @@ namespace mongo { /** * Configuration object describing a bench run activity. */ - class BenchRunConfig : private boost::noncopyable { + class BenchRunConfig { + MONGO_DISALLOW_COPYING(BenchRunConfig); public: /** @@ -138,7 +138,8 @@ namespace mongo { * * Not thread safe. Expected use is one instance per thread during parallel execution. */ - class BenchRunEventCounter : private boost::noncopyable { + class BenchRunEventCounter { + MONGO_DISALLOW_COPYING(BenchRunEventCounter); public: /// Constructs a zeroed out counter. BenchRunEventCounter(); @@ -190,7 +191,8 @@ namespace mongo { * * In all cases, the counter objects must outlive the trace object. */ - class BenchRunEventTrace : private boost::noncopyable { + class BenchRunEventTrace { + MONGO_DISALLOW_COPYING(BenchRunEventTrace); public: explicit BenchRunEventTrace(BenchRunEventCounter *eventCounter) { initialize(eventCounter, eventCounter, false); @@ -227,7 +229,8 @@ namespace mongo { /** * Statistics object representing the result of a bench run activity. */ - class BenchRunStats : private boost::noncopyable { + class BenchRunStats { + MONGO_DISALLOW_COPYING(BenchRunStats); public: BenchRunStats(); ~BenchRunStats(); @@ -254,7 +257,8 @@ namespace mongo { * * Logically, the states are "starting up", "running" and "finished." */ - class BenchRunState : private boost::noncopyable { + class BenchRunState { + MONGO_DISALLOW_COPYING(BenchRunState); public: enum State { BRS_STARTING_UP, BRS_RUNNING, BRS_FINISHED }; @@ -316,7 +320,8 @@ namespace mongo { * * Represents the behavior of one thread working in a bench run activity. */ - class BenchRunWorker : private boost::noncopyable { + class BenchRunWorker { + MONGO_DISALLOW_COPYING(BenchRunWorker); public: /** @@ -363,7 +368,8 @@ namespace mongo { /** * Object representing a "bench run" activity. */ - class BenchRunner : private boost::noncopyable { + class BenchRunner { + MONGO_DISALLOW_COPYING(BenchRunner); public: /** * Utility method to create a new bench runner from a BSONObj representation diff --git a/src/mongo/unittest/unittest.h b/src/mongo/unittest/unittest.h index c44dd8ab41f..53cfb0204a3 100644 --- a/src/mongo/unittest/unittest.h +++ b/src/mongo/unittest/unittest.h @@ -41,7 +41,6 @@ #include <vector> #include <boost/config.hpp> -#include <boost/noncopyable.hpp> #include "mongo/base/status_with.h" #include "mongo/logger/logstream_builder.h" @@ -250,7 +249,8 @@ namespace mongo { * Container holding a test function and its name. Suites * contain lists of these. */ - class TestHolder : private boost::noncopyable { + class TestHolder { + MONGO_DISALLOW_COPYING(TestHolder); public: TestHolder(const std::string& name, const TestFunction& fn) : _name(name), _fn(fn) {} @@ -268,7 +268,8 @@ namespace mongo { * Base type for unit test fixtures. Also, the default fixture type used * by the TEST() macro. */ - class Test : private boost::noncopyable { + class Test { + MONGO_DISALLOW_COPYING(Test); public: Test(); virtual ~Test(); @@ -280,7 +281,8 @@ namespace mongo { * Registration agent for adding tests to suites, used by TEST macro. */ template <typename T> - class RegistrationAgent : private boost::noncopyable { + class RegistrationAgent { + MONGO_DISALLOW_COPYING(RegistrationAgent); public: RegistrationAgent(const std::string& suiteName, const std::string& testName); }; @@ -344,7 +346,8 @@ namespace mongo { * by the programmer by overriding setupTests() in a subclass of Suite. This * approach is deprecated. */ - class Suite : private boost::noncopyable { + class Suite { + MONGO_DISALLOW_COPYING(Suite); public: Suite( const std::string& name ); virtual ~Suite(); diff --git a/src/mongo/util/background.h b/src/mongo/util/background.h index e49bead9491..64b7394f70b 100644 --- a/src/mongo/util/background.h +++ b/src/mongo/util/background.h @@ -29,11 +29,11 @@ #pragma once -#include <boost/noncopyable.hpp> #include <memory> #include <string> #include <vector> +#include "mongo/base/disallow_copying.h" #include "mongo/base/status.h" namespace mongo { @@ -54,7 +54,8 @@ namespace mongo { * BackgroundJob object must exist for as long the background thread is running. */ - class BackgroundJob : boost::noncopyable { + class BackgroundJob { + MONGO_DISALLOW_COPYING(BackgroundJob); protected: /** * sub-class must instantiate the BackgroundJob diff --git a/src/mongo/util/bufreader.h b/src/mongo/util/bufreader.h index 2afb66c3c7a..481d0dbe31b 100644 --- a/src/mongo/util/bufreader.h +++ b/src/mongo/util/bufreader.h @@ -30,8 +30,6 @@ #pragma once -#include <boost/noncopyable.hpp> - #include "mongo/bson/util/builder.h" #include "mongo/util/assert_util.h" @@ -41,7 +39,8 @@ namespace mongo { methods throw the eof exception if the operation would pass the end of the buffer with which we are working. */ - class BufReader : boost::noncopyable { + class BufReader { + MONGO_DISALLOW_COPYING(BufReader); public: class eof : public std::exception { public: diff --git a/src/mongo/util/concurrency/mapsf.h b/src/mongo/util/concurrency/mapsf.h index 190cc3b506e..27e9272f9e7 100644 --- a/src/mongo/util/concurrency/mapsf.h +++ b/src/mongo/util/concurrency/mapsf.h @@ -28,8 +28,6 @@ * then also delete it in the license file. */ -#include <boost/noncopyable.hpp> - #include "mongo/platform/unordered_map.h" namespace mongo { @@ -53,7 +51,9 @@ namespace mongo { } */ template< class M > - struct mapsf : boost::noncopyable { + struct mapsf { + MONGO_DISALLOW_COPYING(mapsf); + SimpleMutex m; M val; friend struct ref; diff --git a/src/mongo/util/concurrency/mutex.h b/src/mongo/util/concurrency/mutex.h index b9f9a361290..fa2aa248930 100644 --- a/src/mongo/util/concurrency/mutex.h +++ b/src/mongo/util/concurrency/mutex.h @@ -33,7 +33,6 @@ #include "mongo/platform/windows_basic.h" #endif -#include <boost/noncopyable.hpp> #include <boost/thread/mutex.hpp> #include "mongo/util/assert_util.h" @@ -44,9 +43,11 @@ namespace mongo { // If you create a local static instance of this class, that instance will be destroyed // before all global static objects are destroyed, so _destroyingStatics will be set // to true before the global static variables are destroyed. - class StaticObserver : boost::noncopyable { + class StaticObserver { + MONGO_DISALLOW_COPYING(StaticObserver); public: static bool _destroyingStatics; + StaticObserver() = default; ~StaticObserver() { _destroyingStatics = true; } }; @@ -58,7 +59,8 @@ namespace mongo { On Windows, the implementation below is faster than boost mutex. */ #if defined(_WIN32) - class SimpleMutex : boost::noncopyable { + class SimpleMutex { + MONGO_DISALLOW_COPYING(SimpleMutex); public: SimpleMutex( StringData ) { InitializeCriticalSection( &_cs ); } ~SimpleMutex() { @@ -81,7 +83,8 @@ namespace mongo { CRITICAL_SECTION _cs; }; #else - class SimpleMutex : boost::noncopyable { + class SimpleMutex { + MONGO_DISALLOW_COPYING(SimpleMutex); public: void dassertLocked() const { } SimpleMutex(StringData name) { verify( pthread_mutex_init(&_lock,0) == 0 ); } @@ -94,7 +97,8 @@ namespace mongo { void lock() { verify( pthread_mutex_lock(&_lock) == 0 ); } void unlock() { verify( pthread_mutex_unlock(&_lock) == 0 ); } public: - class scoped_lock : boost::noncopyable { + class scoped_lock { + MONGO_DISALLOW_COPYING(scoped_lock); SimpleMutex& _m; public: scoped_lock( SimpleMutex &m ) : _m(m) { _m.lock(); } @@ -110,11 +114,14 @@ namespace mongo { /** This can be used instead of boost recursive mutex. The advantage is the debug checks * and ability to assertLocked(). This has not yet been tested for speed vs. the boost one. */ - class RecursiveMutex : boost::noncopyable { + class RecursiveMutex { + MONGO_DISALLOW_COPYING(RecursiveMutex); public: RecursiveMutex(StringData name) : m(name) { } bool isLocked() const { return n.get() > 0; } - class scoped_lock : boost::noncopyable { + class scoped_lock { + MONGO_DISALLOW_COPYING(scoped_lock); + RecursiveMutex& rm; int& nLocksByMe; public: diff --git a/src/mongo/util/concurrency/rwlock.h b/src/mongo/util/concurrency/rwlock.h index 34f2a95eb5f..bb9426a68f3 100644 --- a/src/mongo/util/concurrency/rwlock.h +++ b/src/mongo/util/concurrency/rwlock.h @@ -30,8 +30,6 @@ #pragma once -#include <boost/noncopyable.hpp> - #include "mongo/util/concurrency/mutex.h" #include "mongo/util/concurrency/rwlockimpl.h" #include "mongo/util/concurrency/simplerwlock.h" @@ -78,7 +76,8 @@ namespace mongo { unlocks on destruction, whether in upgradable state or upgraded to exclusive in the interim. */ - class Upgradable : boost::noncopyable { + class Upgradable { + MONGO_DISALLOW_COPYING(Upgradable); RWLock& _r; public: Upgradable(RWLock& r) : _r(r) { @@ -101,7 +100,8 @@ namespace mongo { }; /** throws on failure to acquire in the specified time period. */ - class rwlock_try_write : boost::noncopyable { + class rwlock_try_write { + MONGO_DISALLOW_COPYING(rwlock_try_write); public: struct exception { }; rwlock_try_write(RWLock& l, int millis = 0) : _l(l) { @@ -113,7 +113,8 @@ namespace mongo { RWLock& _l; }; - class rwlock_shared : boost::noncopyable { + class rwlock_shared { + MONGO_DISALLOW_COPYING(rwlock_shared); public: rwlock_shared(RWLock& rwlock) : _r(rwlock) {_r.lock_shared(); } ~rwlock_shared() { _r.unlock_shared(); } @@ -122,7 +123,8 @@ namespace mongo { }; /* scoped lock for RWLock */ - class rwlock : boost::noncopyable { + class rwlock { + MONGO_DISALLOW_COPYING(rwlock); public: /** * @param write acquire write lock if true sharable if false @@ -170,7 +172,8 @@ namespace mongo { verify( _state.get() < 0 ); } - class Exclusive : boost::noncopyable { + class Exclusive { + MONGO_DISALLOW_COPYING(Exclusive); RWLockRecursive& _r; public: Exclusive(RWLockRecursive& r) : _r(r) { @@ -190,7 +193,8 @@ namespace mongo { } }; - class Shared : boost::noncopyable { + class Shared { + MONGO_DISALLOW_COPYING(Shared); RWLockRecursive& _r; bool _alreadyLockedExclusiveByUs; public: diff --git a/src/mongo/util/concurrency/rwlockimpl.cpp b/src/mongo/util/concurrency/rwlockimpl.cpp index b2b6dd5dbcb..22f5a7df54d 100644 --- a/src/mongo/util/concurrency/rwlockimpl.cpp +++ b/src/mongo/util/concurrency/rwlockimpl.cpp @@ -37,7 +37,6 @@ #include <map> #include <set> #include <boost/version.hpp> -#include <boost/noncopyable.hpp> #include <boost/thread/mutex.hpp> #include <boost/thread/condition.hpp> diff --git a/src/mongo/util/concurrency/rwlockimpl.h b/src/mongo/util/concurrency/rwlockimpl.h index adcaa8dc8f6..a591bd389b7 100644 --- a/src/mongo/util/concurrency/rwlockimpl.h +++ b/src/mongo/util/concurrency/rwlockimpl.h @@ -41,7 +41,8 @@ namespace mongo { unsigned long long curTimeMicros64(); - class RWLockBase : boost::noncopyable { + class RWLockBase { + MONGO_DISALLOW_COPYING(RWLockBase); friend class SimpleRWLock; SRWLOCK _lock; protected: @@ -101,10 +102,13 @@ namespace mongo { using boost::shared_mutex; } # endif namespace mongo { - class RWLockBase : boost::noncopyable { + class RWLockBase { + MONGO_DISALLOW_COPYING(RWLockBase); friend class SimpleRWLock; shared_mutex _m; protected: + RWLockBase() = default; + void lock() { _m.lock(); } diff --git a/src/mongo/util/concurrency/shared_mutex_win.hpp b/src/mongo/util/concurrency/shared_mutex_win.hpp index ab0f9f1b3f9..a51afafb52d 100644 --- a/src/mongo/util/concurrency/shared_mutex_win.hpp +++ b/src/mongo/util/concurrency/shared_mutex_win.hpp @@ -35,7 +35,6 @@ #include <boost/assert.hpp>
#include <boost/detail/interlocked.hpp>
-#include <boost/noncopyable.hpp>
#include <boost/thread/win32/thread_primitives.hpp>
#include <boost/static_assert.hpp>
#include <limits.h>
@@ -45,9 +44,9 @@ namespace boost
{
- class modified_shared_mutex:
- private boost::noncopyable
+ class modified_shared_mutex
{
+ MONGO_DISALLOW_COPYING(modified_shared_mutex);
private:
struct state_data
{
diff --git a/src/mongo/util/concurrency/simplerwlock.h b/src/mongo/util/concurrency/simplerwlock.h index 821150e7add..ceee67f50b2 100644 --- a/src/mongo/util/concurrency/simplerwlock.h +++ b/src/mongo/util/concurrency/simplerwlock.h @@ -28,8 +28,6 @@ #pragma once -#include <boost/noncopyable.hpp> - #include "mongo/base/string_data.h" #include "mongo/config.h" #include "mongo/platform/atomic_word.h" @@ -39,7 +37,8 @@ namespace mongo { /** separated out as later the implementation of this may be different than RWLock, depending on OS, as there is no upgrade etc. facility herein. */ - class SimpleRWLock : boost::noncopyable { + class SimpleRWLock { + MONGO_DISALLOW_COPYING(SimpleRWLock); #if defined(NTDDI_VERSION) && defined(NTDDI_WIN7) && (NTDDI_VERSION >= NTDDI_WIN7) SRWLOCK _lock; #else @@ -57,13 +56,15 @@ namespace mongo { void unlock(); void lock_shared(); void unlock_shared(); - class Shared : boost::noncopyable { + class Shared { + MONGO_DISALLOW_COPYING(Shared); SimpleRWLock& _r; public: Shared(SimpleRWLock& rwlock) : _r(rwlock) {_r.lock_shared(); } ~Shared() { _r.unlock_shared(); } }; - class Exclusive : boost::noncopyable { + class Exclusive { + MONGO_DISALLOW_COPYING(Exclusive); SimpleRWLock& _r; public: Exclusive(SimpleRWLock& rwlock) : _r(rwlock) {_r.lock(); } diff --git a/src/mongo/util/concurrency/spin_lock.h b/src/mongo/util/concurrency/spin_lock.h index 2343fdc461a..782edd4f026 100644 --- a/src/mongo/util/concurrency/spin_lock.h +++ b/src/mongo/util/concurrency/spin_lock.h @@ -34,8 +34,6 @@ #include "mongo/platform/windows_basic.h" #endif -#include <boost/noncopyable.hpp> - #include "mutex.h" namespace mongo { @@ -44,7 +42,8 @@ namespace mongo { * The spinlock currently requires late GCC support routines to be efficient. * Other platforms default to a mutex implemenation. */ - class SpinLock : boost::noncopyable { + class SpinLock { + MONGO_DISALLOW_COPYING(SpinLock); public: SpinLock(); ~SpinLock(); @@ -81,7 +80,8 @@ namespace mongo { #endif }; - class scoped_spinlock : boost::noncopyable { + class scoped_spinlock { + MONGO_DISALLOW_COPYING(scoped_spinlock); public: scoped_spinlock( SpinLock& l ) : _l(l) { _l.lock(); diff --git a/src/mongo/util/concurrency/synchronization.h b/src/mongo/util/concurrency/synchronization.h index 39ddc4edce5..2151aa28f53 100644 --- a/src/mongo/util/concurrency/synchronization.h +++ b/src/mongo/util/concurrency/synchronization.h @@ -30,7 +30,6 @@ #pragma once #include <boost/thread/condition.hpp> -#include <boost/noncopyable.hpp> #include "mutex.h" @@ -63,7 +62,8 @@ namespace mongo { * * This class is thread-safe. */ - class Notification : boost::noncopyable { + class Notification { + MONGO_DISALLOW_COPYING(Notification); public: Notification(); @@ -87,7 +87,8 @@ namespace mongo { /** establishes a synchronization point between threads. N threads are waits and one is notifier. threadsafe. */ - class NotifyAll : boost::noncopyable { + class NotifyAll { + MONGO_DISALLOW_COPYING(NotifyAll); public: NotifyAll(); diff --git a/src/mongo/util/intrusive_counter.h b/src/mongo/util/intrusive_counter.h index 39425939820..32159e681fe 100644 --- a/src/mongo/util/intrusive_counter.h +++ b/src/mongo/util/intrusive_counter.h @@ -29,10 +29,10 @@ #pragma once #include <boost/intrusive_ptr.hpp> -#include <boost/noncopyable.hpp> #include <stdlib.h> #include "mongo/platform/atomic_word.h" +#include "mongo/base/disallow_copying.h" #include "mongo/base/string_data.h" #include "mongo/util/allocator.h" @@ -55,9 +55,10 @@ namespace mongo { be used. For static objects, the implementations of addRef() and release() can be overridden to do nothing. */ - class IntrusiveCounter : - boost::noncopyable { + class IntrusiveCounter { + MONGO_DISALLOW_COPYING(IntrusiveCounter); public: + IntrusiveCounter() = default; virtual ~IntrusiveCounter() {}; // these are here for the boost intrusive_ptr<> class @@ -84,7 +85,8 @@ namespace mongo { }; /// This is an alternative base class to the above ones (will replace them eventually) - class RefCountable : boost::noncopyable { + class RefCountable { + MONGO_DISALLOW_COPYING(RefCountable); public: /// If false you have exclusive access to this object. This is useful for implementing COW. bool isShared() const { diff --git a/src/mongo/util/net/httpclient.h b/src/mongo/util/net/httpclient.h index c2297547fed..18c66aee25c 100644 --- a/src/mongo/util/net/httpclient.h +++ b/src/mongo/util/net/httpclient.h @@ -29,15 +29,16 @@ #pragma once +#include "mongo/base/disallow_copying.h" #include "mongo/platform/basic.h" -#include <boost/noncopyable.hpp> #include <map> #include <string> namespace mongo { - class HttpClient : boost::noncopyable { + class HttpClient { + MONGO_DISALLOW_COPYING(HttpClient); public: typedef std::map<std::string,std::string> Headers; diff --git a/src/mongo/util/net/listen.h b/src/mongo/util/net/listen.h index 2db88ffb141..253b936959d 100644 --- a/src/mongo/util/net/listen.h +++ b/src/mongo/util/net/listen.h @@ -29,7 +29,6 @@ #pragma once -#include <boost/noncopyable.hpp> #include <boost/thread/mutex.hpp> #include <boost/thread/condition_variable.hpp> #include <set> @@ -47,7 +46,8 @@ namespace mongo { class MessagingPort; - class Listener : boost::noncopyable { + class Listener { + MONGO_DISALLOW_COPYING(Listener); public: Listener(const std::string& name, const std::string &ip, int port, bool logConnect=true ); diff --git a/src/mongo/util/net/message_port.h b/src/mongo/util/net/message_port.h index 161b30037af..7843621bf5e 100644 --- a/src/mongo/util/net/message_port.h +++ b/src/mongo/util/net/message_port.h @@ -29,7 +29,6 @@ #pragma once -#include <boost/noncopyable.hpp> #include <vector> #include "mongo/config.h" @@ -41,7 +40,8 @@ namespace mongo { class MessagingPort; class PiggyBackData; - class AbstractMessagingPort : boost::noncopyable { + class AbstractMessagingPort { + MONGO_DISALLOW_COPYING(AbstractMessagingPort); public: AbstractMessagingPort() : tag(0), _connectionId(0) {} virtual ~AbstractMessagingPort() { } diff --git a/src/mongo/util/progress_meter.h b/src/mongo/util/progress_meter.h index bdcc83ddd14..39bd2790ad7 100644 --- a/src/mongo/util/progress_meter.h +++ b/src/mongo/util/progress_meter.h @@ -30,13 +30,13 @@ #pragma once #include "mongo/util/thread_safe_string.h" -#include <boost/noncopyable.hpp> #include <string> namespace mongo { - class ProgressMeter : boost::noncopyable { + class ProgressMeter { + MONGO_DISALLOW_COPYING(ProgressMeter); public: ProgressMeter(unsigned long long total, int secondsBetween = 3, @@ -110,7 +110,8 @@ namespace mongo { // CurOp * op = CurOp::get(txn); // ProgressMeterHolder pm(op->setMessage("index: (1/3) external sort", "Index: External Sort Progress", d->stats.nrecords, 10)); // loop { pm.hit(); } - class ProgressMeterHolder : boost::noncopyable { + class ProgressMeterHolder { + MONGO_DISALLOW_COPYING(ProgressMeterHolder); public: ProgressMeterHolder( ProgressMeter& pm ) : _pm( pm ) { diff --git a/src/mongo/util/thread_safe_string.h b/src/mongo/util/thread_safe_string.h index b34315c1967..f7fa7aa93e1 100644 --- a/src/mongo/util/thread_safe_string.h +++ b/src/mongo/util/thread_safe_string.h @@ -32,8 +32,7 @@ #include <iosfwd> #include <string> -#include <boost/noncopyable.hpp> - +#include "mongo/base/disallow_copying.h" #include "mongo/base/string_data.h" namespace mongo { @@ -42,7 +41,8 @@ namespace mongo { * this is a thread safe string * you will never get a bad pointer, though data may be mungedd */ - class ThreadSafeString : boost::noncopyable { + class ThreadSafeString { + MONGO_DISALLOW_COPYING(ThreadSafeString); public: ThreadSafeString( size_t size=256 ) : _size( size ) , _buf( new char[size] ) { |