Use deleted members to prevent copying in Beast (RIPD-268)

This commit is contained in:
Nik Bougalis
2014-09-25 11:13:38 -07:00
committed by Vinnie Falco
parent cd97b5beec
commit 60330da25c
48 changed files with 255 additions and 191 deletions

View File

@@ -39,13 +39,16 @@ namespace beast {
@see ScopedLock, ScopedTryLock, ScopedUnlock, SpinLock, Thread
*/
class CriticalSection : public Uncopyable
class CriticalSection
{
public:
//==============================================================================
/** Creates a CriticalSection object. */
CriticalSection() noexcept;
CriticalSection (CriticalSection const&) = delete;
CriticalSection& operator= (CriticalSection const&) = delete;
/** Destructor.
If the critical section is deleted whilst locked, any subsequent behaviour
is unpredictable.
@@ -138,11 +141,13 @@ private:
@see CriticalSection, Array, SharedObjectArray
*/
class DummyCriticalSection : public Uncopyable
class DummyCriticalSection
{
public:
inline DummyCriticalSection() noexcept {}
inline ~DummyCriticalSection() noexcept {}
DummyCriticalSection() = default;
DummyCriticalSection (DummyCriticalSection const&) = delete;
DummyCriticalSection& operator= (DummyCriticalSection const&) = delete;
~DummyCriticalSection() = default;
inline void enter() const noexcept {}
inline bool tryEnter() const noexcept { return true; }

View File

@@ -34,7 +34,7 @@ namespace beast
Since the DLL is freed when this object is deleted, it's handy for managing
library lifetimes using RAII.
*/
class DynamicLibrary : LeakChecked <DynamicLibrary>, public Uncopyable
class DynamicLibrary : LeakChecked <DynamicLibrary>
{
public:
/** Creates an unopened DynamicLibrary object.
@@ -46,6 +46,9 @@ public:
*/
DynamicLibrary (const String& name) : handle (nullptr) { open (name); }
DynamicLibrary (DynamicLibrary const&) = delete;
DynamicLibrary& operator= (DynamicLibrary const&) = delete;
/** Destructor.
If a library is currently open, it will be closed when this object is destroyed.
*/

View File

@@ -34,7 +34,7 @@ namespace beast {
@see Thread, BEASTApplication
*/
class Process : public Uncopyable
class Process
{
public:
//==============================================================================
@@ -130,7 +130,9 @@ public:
#endif
private:
Process();
Process() = delete;
Process (Process const&) = delete;
Process const& operator= (Process const&) = delete;
};
} // beast

View File

@@ -53,7 +53,7 @@ namespace beast
@see GenericScopedUnlock, CriticalSection, SpinLock, ScopedLock, ScopedUnlock
*/
template <class LockType>
class GenericScopedLock : public Uncopyable
class GenericScopedLock
{
public:
//==============================================================================
@@ -72,6 +72,9 @@ public:
lock.enter();
}
GenericScopedLock (GenericScopedLock const&) = delete;
GenericScopedLock& operator= (GenericScopedLock const&) = delete;
/** Destructor.
The lock will be released when the destructor is called.
Make sure this object is created and deleted by the same thread, otherwise there are
@@ -126,7 +129,7 @@ private:
@see GenericScopedLock, CriticalSection, ScopedLock, ScopedUnlock
*/
template <class LockType>
class GenericScopedUnlock : public Uncopyable
class GenericScopedUnlock
{
public:
//==============================================================================
@@ -146,6 +149,9 @@ public:
lock.unlock();
}
GenericScopedUnlock (GenericScopedUnlock const&) = delete;
GenericScopedUnlock& operator= (GenericScopedUnlock const&) = delete;
/** Destructor.
The CriticalSection will be unlocked when the destructor is called.
@@ -200,7 +206,7 @@ private:
@see CriticalSection::tryEnter, GenericScopedLock, GenericScopedUnlock
*/
template <class LockType>
class GenericScopedTryLock : public Uncopyable
class GenericScopedTryLock
{
public:
//==============================================================================
@@ -217,6 +223,9 @@ public:
inline explicit GenericScopedTryLock (const LockType& lock) noexcept
: lock_ (lock), lockWasSuccessful (lock.tryEnter()) {}
GenericScopedTryLock (GenericScopedTryLock const&) = delete;
GenericScopedTryLock& operator= (GenericScopedTryLock const&) = delete;
/** Destructor.
The mutex will be unlocked (if it had been successfully locked) when the