Commit eba1ff75 authored by Joe Loser's avatar Joe Loser Committed by Facebook Github Bot

Replace boost::noncopyable with deleted copy constructors

Summary: Pull Request resolved: https://github.com/facebook/folly/pull/1014

Reviewed By: lbrandy

Differential Revision: D14019229

Pulled By: yfeldblum

fbshipit-source-id: dd07d567a7f176a3bb0e18f7a19c3babfe2d431d
parent 56051aed
......@@ -22,8 +22,6 @@
#include <cstddef>
#include <limits>
#include <boost/noncopyable.hpp>
#include <folly/Portability.h>
namespace folly {
......@@ -32,13 +30,16 @@ namespace folly {
* An atomic bitset of fixed size (specified at compile time).
*/
template <size_t N>
class AtomicBitSet : private boost::noncopyable {
class AtomicBitSet {
public:
/**
* Construct an AtomicBitSet; all bits are initially false.
*/
AtomicBitSet();
AtomicBitSet(const AtomicBitSet&) = delete;
AtomicBitSet& operator=(const AtomicBitSet&) = delete;
/**
* Set bit idx to true, using the given memory order. Returns the
* previous value of the bit.
......
......@@ -35,7 +35,6 @@
#include <atomic>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/noncopyable.hpp>
#include <folly/ThreadCachedInt.h>
#include <folly/Utility.h>
......@@ -102,7 +101,7 @@ template <
class Allocator = std::allocator<char>,
class ProbeFcn = AtomicHashArrayLinearProbeFcn,
class KeyConvertFcn = Identity>
class AtomicHashArray : boost::noncopyable {
class AtomicHashArray {
static_assert(
(std::is_convertible<KeyT, int32_t>::value ||
std::is_convertible<KeyT, int64_t>::value ||
......@@ -422,6 +421,9 @@ class AtomicHashArray : boost::noncopyable {
double maxLoadFactor,
uint32_t cacheSize);
AtomicHashArray(const AtomicHashArray&) = delete;
AtomicHashArray& operator=(const AtomicHashArray&) = delete;
~AtomicHashArray() = default;
inline void unlockCell(value_type* const cell, KeyT newKey) {
......
......@@ -82,7 +82,6 @@
#define FOLLY_ATOMICHASHMAP_H_
#include <boost/iterator/iterator_facade.hpp>
#include <boost/noncopyable.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <atomic>
......@@ -162,7 +161,7 @@ template <
class Allocator,
class ProbeFcn,
class KeyConvertFcn>
class AtomicHashMap : boost::noncopyable {
class AtomicHashMap {
typedef AtomicHashArray<
KeyT,
ValueT,
......@@ -206,6 +205,9 @@ class AtomicHashMap : boost::noncopyable {
// and a Config object to specify more advanced options.
explicit AtomicHashMap(size_t finalSizeEst, const Config& c = Config());
AtomicHashMap(const AtomicHashMap&) = delete;
AtomicHashMap& operator=(const AtomicHashMap&) = delete;
~AtomicHashMap() {
const unsigned int numMaps =
numMapsAllocated_.load(std::memory_order_relaxed);
......
......@@ -27,7 +27,6 @@
#include <type_traits>
#include <vector>
#include <boost/noncopyable.hpp>
#include <boost/random.hpp>
#include <boost/type_traits.hpp>
#include <glog/logging.h>
......@@ -43,7 +42,7 @@ template <typename ValT, typename NodeT>
class csl_iterator;
template <typename T>
class SkipListNode : private boost::noncopyable {
class SkipListNode {
enum : uint16_t {
IS_HEAD_NODE = 1,
MARKED_FOR_REMOVAL = (1 << 1),
......@@ -53,6 +52,9 @@ class SkipListNode : private boost::noncopyable {
public:
typedef T value_type;
SkipListNode(const SkipListNode&) = delete;
SkipListNode& operator=(const SkipListNode&) = delete;
template <
typename NodeAlloc,
typename U,
......
......@@ -22,7 +22,6 @@
#include <type_traits>
#include <boost/noncopyable.hpp>
#include <folly/Portability.h>
#include <folly/concurrency/CacheLocality.h>
#include <folly/portability/SysMman.h>
......@@ -156,12 +155,15 @@ template <
uint32_t LocalListLimit_ = 200,
template <typename> class Atom = std::atomic,
typename Traits = IndexedMemPoolTraits<T>>
struct IndexedMemPool : boost::noncopyable {
struct IndexedMemPool {
typedef T value_type;
typedef std::unique_ptr<T, detail::IndexedMemPoolRecycler<IndexedMemPool>>
UniquePtr;
IndexedMemPool(const IndexedMemPool&) = delete;
IndexedMemPool& operator=(const IndexedMemPool&) = delete;
static_assert(LocalListLimit_ <= 255, "LocalListLimit must fit in 8 bits");
enum {
NumLocalLists = NumLocalLists_,
......
......@@ -23,8 +23,6 @@
#include <limits>
#include <type_traits>
#include <boost/noncopyable.hpp>
#include <folly/Traits.h>
#include <folly/concurrency/CacheLocality.h>
#include <folly/detail/TurnSequencer.h>
......@@ -640,7 +638,7 @@ template <
typename T,
template <typename> class Atom,
bool Dynamic>
class MPMCQueueBase<Derived<T, Atom, Dynamic>> : boost::noncopyable {
class MPMCQueueBase<Derived<T, Atom, Dynamic>> {
// Note: Using CRTP static casts in several functions of this base
// template instead of making called functions virtual or duplicating
// the code of calling functions in the derived partially specialized
......@@ -733,6 +731,9 @@ class MPMCQueueBase<Derived<T, Atom, Dynamic>> : boost::noncopyable {
return *this;
}
MPMCQueueBase(const MPMCQueueBase&) = delete;
MPMCQueueBase& operator=(const MPMCQueueBase&) = delete;
/// MPMCQueue can only be safely destroyed when there are no
/// pending enqueuers or dequeuers (this is not checked).
~MPMCQueueBase() {
......
......@@ -34,8 +34,6 @@
#include <type_traits>
#include <boost/noncopyable.hpp>
#include <folly/Portability.h>
#include <folly/synchronization/SmallLocks.h>
......@@ -61,13 +59,17 @@ class SpinLock {
};
template <typename LOCK>
class SpinLockGuardImpl : private boost::noncopyable {
class SpinLockGuardImpl {
public:
FOLLY_ALWAYS_INLINE explicit SpinLockGuardImpl(LOCK& lock) noexcept(
noexcept(lock.lock()))
: lock_(lock) {
lock_.lock();
}
SpinLockGuardImpl(const SpinLockGuardImpl&) = delete;
SpinLockGuardImpl& operator=(const SpinLockGuardImpl&) = delete;
FOLLY_ALWAYS_INLINE ~SpinLockGuardImpl() {
lock_.unlock();
}
......
......@@ -24,8 +24,6 @@
#include <atomic>
#include <boost/noncopyable.hpp>
#include <folly/Likely.h>
#include <folly/ThreadLocal.h>
......@@ -36,13 +34,16 @@ namespace folly {
// ThreadCachedInt's you should considering breaking up the Tag space even
// further.
template <class IntT, class Tag = IntT>
class ThreadCachedInt : boost::noncopyable {
class ThreadCachedInt {
struct IntCache;
public:
explicit ThreadCachedInt(IntT initialVal = 0, uint32_t cacheSize = 1000)
: target_(initialVal), cacheSize_(cacheSize) {}
ThreadCachedInt(const ThreadCachedInt&) = delete;
ThreadCachedInt& operator=(const ThreadCachedInt&) = delete;
void increment(IntT inc) {
auto cache = cache_.get();
if (UNLIKELY(cache == nullptr)) {
......
......@@ -98,7 +98,6 @@ class TimeoutQueue {
private:
int64_t runInternal(int64_t now, bool runOnce);
// noncopyable
TimeoutQueue(const TimeoutQueue&) = delete;
TimeoutQueue& operator=(const TimeoutQueue&) = delete;
......
......@@ -23,7 +23,6 @@
#include <unordered_map>
#include <utility>
#include <boost/noncopyable.hpp>
#include <glog/logging.h>
#include <folly/Random.h>
......@@ -48,8 +47,10 @@ namespace folly {
namespace io {
namespace test {
class DataHolder : private boost::noncopyable {
class DataHolder {
public:
DataHolder(const DataHolder&) = delete;
DataHolder& operator=(const DataHolder&) = delete;
uint64_t hash(size_t size) const;
ByteRange data(size_t size) const;
......
......@@ -22,8 +22,6 @@
#include <memory>
#include <type_traits>
#include <boost/noncopyable.hpp>
#include <folly/Portability.h>
#include <folly/Traits.h>
#include <folly/detail/TurnSequencer.h>
......@@ -56,7 +54,7 @@ class RingBufferSlot;
///
template <typename T, template <typename> class Atom = std::atomic>
class LockFreeRingBuffer : boost::noncopyable {
class LockFreeRingBuffer {
static_assert(
std::is_nothrow_default_constructible<T>::value,
"Element type must be nothrow default constructible");
......@@ -101,6 +99,9 @@ class LockFreeRingBuffer : boost::noncopyable {
slots_(new detail::RingBufferSlot<T, Atom>[capacity]),
ticket_(0) {}
LockFreeRingBuffer(const LockFreeRingBuffer&) = delete;
LockFreeRingBuffer& operator=(const LockFreeRingBuffer&) = delete;
/// Perform a single write of an object of type T.
/// Writes can block iff a previous writer has not yet completed a write
/// for the same slot (before the most recent wrap-around).
......
......@@ -27,7 +27,6 @@
#include <utility>
#include <vector>
#include <boost/noncopyable.hpp>
#include <libaio.h>
#include <folly/Portability.h>
......@@ -42,7 +41,7 @@ namespace folly {
*
* The op must remain allocated until it is completed or canceled.
*/
class AsyncIOOp : private boost::noncopyable {
class AsyncIOOp {
friend class AsyncIO;
friend std::ostream& operator<<(std::ostream& stream, const AsyncIOOp& o);
......@@ -50,6 +49,8 @@ class AsyncIOOp : private boost::noncopyable {
typedef std::function<void(AsyncIOOp*)> NotificationCallback;
explicit AsyncIOOp(NotificationCallback cb = NotificationCallback());
AsyncIOOp(const AsyncIOOp&) = delete;
AsyncIOOp& operator=(const AsyncIOOp&) = delete;
~AsyncIOOp();
enum class State {
......@@ -122,7 +123,7 @@ std::ostream& operator<<(std::ostream& stream, AsyncIOOp::State state);
/**
* C++ interface around Linux Async IO.
*/
class AsyncIO : private boost::noncopyable {
class AsyncIO {
public:
typedef AsyncIOOp Op;
......@@ -152,6 +153,8 @@ class AsyncIO : private boost::noncopyable {
* of the current number of pending requests.
*/
explicit AsyncIO(size_t capacity, PollMode pollMode = NOT_POLLABLE);
AsyncIO(const AsyncIO&) = delete;
AsyncIO& operator=(const AsyncIO&) = delete;
~AsyncIO();
/**
......
......@@ -18,8 +18,6 @@
#include <cstddef>
#include <boost/noncopyable.hpp>
#include <folly/Range.h>
namespace folly {
......@@ -28,7 +26,7 @@ namespace symbolizer {
/**
* Async-signal-safe line reader.
*/
class LineReader : private boost::noncopyable {
class LineReader {
public:
/**
* Create a line reader that reads into a user-provided buffer (of size
......@@ -36,6 +34,9 @@ class LineReader : private boost::noncopyable {
*/
LineReader(int fd, char* buf, size_t bufSize);
LineReader(const LineReader&) = delete;
LineReader& operator=(const LineReader&) = delete;
enum State {
kReading,
kEof,
......
......@@ -20,8 +20,6 @@
#include <cstdlib>
#include <memory>
#include <boost/noncopyable.hpp>
#include <folly/File.h>
#include <folly/net/NetworkSocket.h>
......@@ -30,7 +28,7 @@ namespace folly {
/**
* Set of sockets that allows immediate, take-no-prisoners abort.
*/
class ShutdownSocketSet : private boost::noncopyable {
class ShutdownSocketSet {
public:
/**
* Create a socket set that can handle file descriptors < maxFd.
......@@ -40,6 +38,9 @@ class ShutdownSocketSet : private boost::noncopyable {
*/
explicit ShutdownSocketSet(int maxFd = 1 << 18);
ShutdownSocketSet(const ShutdownSocketSet&) = delete;
ShutdownSocketSet& operator=(const ShutdownSocketSet&) = delete;
/**
* Add an already open socket to the list of sockets managed by
* ShutdownSocketSet. You MUST close the socket by calling
......
......@@ -20,7 +20,6 @@
#include <folly/portability/Event.h>
#include <boost/noncopyable.hpp>
#include <memory>
#include <utility>
......@@ -32,7 +31,7 @@ class RequestContext;
/**
* AsyncTimeout is used to asynchronously wait for a timeout to occur.
*/
class AsyncTimeout : private boost::noncopyable {
class AsyncTimeout {
public:
typedef TimeoutManager::InternalEnum InternalEnum;
......@@ -66,6 +65,9 @@ class AsyncTimeout : private boost::noncopyable {
*/
AsyncTimeout();
AsyncTimeout(const AsyncTimeout&) = delete;
AsyncTimeout& operator=(const AsyncTimeout&) = delete;
/**
* AsyncTimeout destructor.
*
......
......@@ -125,8 +125,7 @@ class VirtualEventBase;
* EventBase from other threads. When it is safe to call a method from
* another thread it is explicitly listed in the method comments.
*/
class EventBase : private boost::noncopyable,
public TimeoutManager,
class EventBase : public TimeoutManager,
public DrivableExecutor,
public IOExecutor,
public SequencedExecutor,
......@@ -293,6 +292,9 @@ class EventBase : private boost::noncopyable,
*/
explicit EventBase(bool enableTimeMeasurement);
EventBase(const EventBase&) = delete;
EventBase& operator=(const EventBase&) = delete;
/**
* Create a new EventBase object that will use the specified libevent
* event_base object to drive the event loop.
......
......@@ -16,7 +16,6 @@
#pragma once
#include <boost/noncopyable.hpp>
#include <folly/Synchronized.h>
#include <folly/io/async/EventBase.h>
#include <memory>
......@@ -28,9 +27,11 @@ namespace folly {
namespace detail {
class EventBaseLocalBase : public EventBaseLocalBaseBase, boost::noncopyable {
class EventBaseLocalBase : public EventBaseLocalBaseBase {
public:
EventBaseLocalBase() {}
EventBaseLocalBase(const EventBaseLocalBase&) = delete;
EventBaseLocalBase& operator=(const EventBaseLocalBase&) = delete;
~EventBaseLocalBase() override;
void erase(EventBase& evb);
void onEventBaseDestruction(EventBase& evb) override;
......
......@@ -18,7 +18,6 @@
#include <cstddef>
#include <boost/noncopyable.hpp>
#include <glog/logging.h>
#include <folly/io/async/EventUtil.h>
......@@ -36,7 +35,7 @@ class EventBase;
* Users that wish to wait on I/O events should derive from EventHandler and
* implement the handlerReady() method.
*/
class EventHandler : private boost::noncopyable {
class EventHandler {
public:
enum EventFlags {
NONE = 0,
......@@ -68,6 +67,9 @@ class EventHandler : private boost::noncopyable {
EventBase* eventBase = nullptr,
NetworkSocket fd = NetworkSocket());
EventHandler(const EventHandler&) = delete;
EventHandler& operator=(const EventHandler&) = delete;
/**
* EventHandler destructor.
*
......
......@@ -368,7 +368,7 @@ void MemoryMapping::advise(int advice, size_t offset, size_t length) const {
PLOG_IF(WARNING, ::madvise(mapStart, length, advice)) << "madvise";
}
MemoryMapping& MemoryMapping::operator=(MemoryMapping other) {
MemoryMapping& MemoryMapping::operator=(MemoryMapping&& other) {
swap(other);
return *this;
}
......
......@@ -16,7 +16,6 @@
#pragma once
#include <boost/noncopyable.hpp>
#include <glog/logging.h>
#include <folly/File.h>
......@@ -29,7 +28,7 @@ namespace folly {
*
* @author Tudor Bosman (tudorb@fb.com)
*/
class MemoryMapping : boost::noncopyable {
class MemoryMapping {
public:
/**
* Lock the pages in memory?
......@@ -147,11 +146,13 @@ class MemoryMapping : boost::noncopyable {
off_t length = -1,
Options options = Options());
MemoryMapping(const MemoryMapping&) = delete;
MemoryMapping(MemoryMapping&&) noexcept;
~MemoryMapping();
MemoryMapping& operator=(MemoryMapping);
MemoryMapping& operator=(const MemoryMapping&) = delete;
MemoryMapping& operator=(MemoryMapping&&);
void swap(MemoryMapping& other) noexcept;
......
......@@ -17,7 +17,6 @@
#pragma once
#include <assert.h>
#include <boost/noncopyable.hpp>
#include <errno.h>
#include <glog/logging.h>
#include <atomic>
......@@ -144,7 +143,7 @@ class ThreadSyncVar {
* Invocations of the scheduler function will be serialized, but will
* occur from multiple threads. A good starting schedule is uniform(0).
*/
class DeterministicSchedule : boost::noncopyable {
class DeterministicSchedule {
public:
/**
* Arranges for the current thread (and all threads created by
......@@ -154,6 +153,9 @@ class DeterministicSchedule : boost::noncopyable {
explicit DeterministicSchedule(
const std::function<size_t(size_t)>& scheduler);
DeterministicSchedule(const DeterministicSchedule&) = delete;
DeterministicSchedule& operator=(const DeterministicSchedule&) = delete;
/** Completes the schedule. */
~DeterministicSchedule();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment