mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 19:45:53 +00:00
Use LeakChecked throughout Beast
This commit is contained in:
@@ -63,8 +63,7 @@
|
||||
/** Config: BEAST_CHECK_MEMORY_LEAKS
|
||||
|
||||
Enables a memory-leak check for certain objects when the app terminates.
|
||||
See the LeakedObjectDetector and LeakChecked classes, and the
|
||||
BEAST_LEAK_DETECTOR macro for more details about enabling leak checking for
|
||||
See the LeakChecked class for more details about enabling leak checking for
|
||||
specific classes.
|
||||
*/
|
||||
#ifndef BEAST_CHECK_MEMORY_LEAKS
|
||||
|
||||
@@ -1632,7 +1632,6 @@
|
||||
<ClInclude Include="..\..\modules\ripple_data\protocol\ripple_TxFlags.h" />
|
||||
<ClInclude Include="..\..\modules\ripple_data\protocol\ripple_TxFormats.h" />
|
||||
<ClInclude Include="..\..\modules\ripple_data\ripple_data.h" />
|
||||
<ClInclude Include="..\..\modules\ripple_data\utility\ripple_JSONCache.h" />
|
||||
<ClInclude Include="..\..\modules\ripple_data\utility\ripple_UptimeTimerAdapter.h" />
|
||||
<ClInclude Include="..\..\modules\ripple_json\json\json_autolink.h" />
|
||||
<ClInclude Include="..\..\modules\ripple_json\json\json_batchallocator.h" />
|
||||
|
||||
@@ -1788,7 +1788,6 @@
|
||||
<ClInclude Include="..\..\modules\ripple_app\basics\ripple_BuildVersion.h">
|
||||
<Filter>1. Modules\ripple_app\basics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\ripple_data\utility\ripple_JSONCache.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\src\cpp\protobuf\src\google\protobuf\descriptor.proto">
|
||||
|
||||
@@ -63,8 +63,7 @@
|
||||
/** Config: BEAST_CHECK_MEMORY_LEAKS
|
||||
|
||||
Enables a memory-leak check for certain objects when the app terminates.
|
||||
See the LeakedObjectDetector and LeakChecked classes, and the
|
||||
BEAST_LEAK_DETECTOR macro for more details about enabling leak checking for
|
||||
See the LeakChecked class for more details about enabling leak checking for
|
||||
specific classes.
|
||||
*/
|
||||
#ifndef BEAST_CHECK_MEMORY_LEAKS
|
||||
|
||||
@@ -143,7 +143,6 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_ByteOrder.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_CacheLine.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_HeapBlock.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_LeakedObjectDetector.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_Memory.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_MemoryAlignment.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_MemoryBlock.h" />
|
||||
@@ -152,6 +151,7 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_ScopedPointer.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_Singleton.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_StaticObject.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_Uncopyable.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_WeakReference.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\misc\beast_Result.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\misc\beast_Uuid.h" />
|
||||
@@ -749,6 +749,12 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\threads\beast_SpinDelay.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\threads\beast_Thread.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
|
||||
@@ -226,9 +226,6 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_HeapBlock.h">
|
||||
<Filter>beast_core\memory</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_LeakedObjectDetector.h">
|
||||
<Filter>beast_core\memory</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_Memory.h">
|
||||
<Filter>beast_core\memory</Filter>
|
||||
</ClInclude>
|
||||
@@ -617,6 +614,9 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\diagnostic\beast_Throw.h">
|
||||
<Filter>beast_core\diagnostic</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_Uncopyable.h">
|
||||
<Filter>beast_core\memory</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\modules\beast_core\beast_core.cpp">
|
||||
@@ -952,5 +952,8 @@
|
||||
<ClCompile Include="..\..\modules\beast_core\diagnostic\beast_LeakChecked.cpp">
|
||||
<Filter>beast_core\diagnostic</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\threads\beast_SpinDelay.cpp">
|
||||
<Filter>beast_core\threads</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -24,7 +24,12 @@
|
||||
|
||||
@ingroup beast_concurrent
|
||||
*/
|
||||
#if 0//BEAST_BOOST_IS_AVAILABLE
|
||||
// VFALCO NOTE Disabled this because it seems that the TLS
|
||||
// implementation has a leak. Although the other
|
||||
// one also seems to have a leak.
|
||||
//
|
||||
//#if BEAST_BOOST_IS_AVAILABLE
|
||||
#if 0
|
||||
typedef FifoFreeStoreWithTLS FifoFreeStoreType;
|
||||
#else
|
||||
typedef FifoFreeStoreWithoutTLS FifoFreeStoreType;
|
||||
|
||||
@@ -20,24 +20,28 @@
|
||||
#ifndef BEAST_REFERENCECOUNTEDSINGLETON_BEASTHEADER
|
||||
#define BEAST_REFERENCECOUNTEDSINGLETON_BEASTHEADER
|
||||
|
||||
/**
|
||||
Thread-safe singleton which comes into existence on first use. Use this
|
||||
instead of creating objects with static storage duration. These singletons
|
||||
are automatically reference counted, so if you hold a pointer to it in every
|
||||
object that depends on it, the order of destruction of objects is assured
|
||||
to be correct.
|
||||
/** Thread-safe singleton which comes into existence on first use. Use this
|
||||
instead of creating objects with static storage duration. These singletons
|
||||
are automatically reference counted, so if you hold a pointer to it in every
|
||||
object that depends on it, the order of destruction of objects is assured
|
||||
to be correct.
|
||||
|
||||
class Object must provide the function `Object* Object::createInstance()`
|
||||
class Object must provide the function `Object* Object::createInstance()`
|
||||
|
||||
@class RefCountedSingleton
|
||||
@ingroup beast_core
|
||||
@class RefCountedSingleton
|
||||
@ingroup beast_core
|
||||
*/
|
||||
/** @{ */
|
||||
class BEAST_API SingletonLifetime
|
||||
{
|
||||
// "base classes dependent on a template parameter
|
||||
// aren't part of lookup." - ville
|
||||
public:
|
||||
// It would be nice if we didn't have to qualify the enumeration but
|
||||
// Argument Dependent Lookup is inapplicable here because:
|
||||
//
|
||||
// "Base classes dependent on a template parameter aren't part of lookup."
|
||||
// - ville
|
||||
//
|
||||
|
||||
/** Construction options for RefCountedSingleton
|
||||
|
||||
@ingroup beast_core
|
||||
@@ -59,6 +63,8 @@ public:
|
||||
};
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template <class Object>
|
||||
class RefCountedSingleton
|
||||
: public SingletonLifetime
|
||||
|
||||
@@ -183,6 +183,7 @@ namespace beast
|
||||
#include "streams/beast_MemoryOutputStream.cpp"
|
||||
#include "streams/beast_OutputStream.cpp"
|
||||
#include "streams/beast_SubregionStream.cpp"
|
||||
|
||||
#include "system/beast_SystemStats.cpp"
|
||||
|
||||
#include "text/beast_CharacterFunctions.cpp"
|
||||
@@ -197,6 +198,7 @@ namespace beast
|
||||
|
||||
#include "threads/beast_ChildProcess.cpp"
|
||||
#include "threads/beast_ReadWriteLock.cpp"
|
||||
#include "threads/beast_SpinDelay.cpp"
|
||||
#include "threads/beast_Thread.cpp"
|
||||
#include "threads/beast_ThreadPool.cpp"
|
||||
#include "threads/beast_TimeSliceThread.cpp"
|
||||
|
||||
@@ -198,17 +198,24 @@ namespace beast
|
||||
// Order matters, since headers don't have their own #include lines.
|
||||
// Add new includes to the bottom.
|
||||
|
||||
#include "threads/beast_Thread.h"
|
||||
#include "threads/beast_SpinDelay.h"
|
||||
#include "memory/beast_Uncopyable.h"
|
||||
#include "maths/beast_MathsFunctions.h"
|
||||
#include "memory/beast_Atomic.h"
|
||||
#include "memory/beast_AtomicCounter.h"
|
||||
#include "memory/beast_AtomicFlag.h"
|
||||
#include "memory/beast_AtomicPointer.h"
|
||||
#include "memory/beast_AtomicState.h"
|
||||
#include "containers/beast_LockFreeStack.h"
|
||||
#include "threads/beast_SpinDelay.h"
|
||||
#include "memory/beast_StaticObject.h"
|
||||
#include "diagnostic/beast_LeakChecked.h"
|
||||
|
||||
#include "memory/beast_Memory.h"
|
||||
#include "memory/beast_ByteOrder.h"
|
||||
#include "logging/beast_Logger.h"
|
||||
|
||||
#include "threads/beast_Thread.h"
|
||||
|
||||
#include "diagnostic/beast_Debug.h"
|
||||
#include "diagnostic/beast_SafeBool.h"
|
||||
#include "diagnostic/beast_Error.h"
|
||||
@@ -251,7 +258,6 @@ namespace beast
|
||||
#include "maths/beast_Range.h"
|
||||
#include "memory/beast_ByteOrder.h"
|
||||
#include "memory/beast_HeapBlock.h"
|
||||
#include "memory/beast_LeakedObjectDetector.h"
|
||||
#include "memory/beast_Memory.h"
|
||||
#include "memory/beast_MemoryBlock.h"
|
||||
#include "memory/beast_OptionalScopedPointer.h"
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
};
|
||||
@endcode
|
||||
*/
|
||||
class BEAST_API AbstractFifo
|
||||
class BEAST_API AbstractFifo : LeakChecked <AbstractFifo>, Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -206,8 +206,6 @@ private:
|
||||
//==============================================================================
|
||||
int bufferSize;
|
||||
Atomic <int> validStart, validEnd;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AbstractFifo)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
@see Array, OwnedArray, ReferenceCountedArray
|
||||
*/
|
||||
template <class ElementType, class TypeOfCriticalSectionToUse>
|
||||
class ArrayAllocationBase : public TypeOfCriticalSectionToUse
|
||||
class ArrayAllocationBase
|
||||
: public TypeOfCriticalSectionToUse
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -126,9 +127,6 @@ public:
|
||||
//==============================================================================
|
||||
HeapBlock <ElementType> elements;
|
||||
int numAllocated;
|
||||
|
||||
private:
|
||||
BEAST_DECLARE_NON_COPYABLE (ArrayAllocationBase)
|
||||
};
|
||||
|
||||
#endif // BEAST_ARRAYALLOCATIONBASE_BEASTHEADER
|
||||
|
||||
@@ -39,7 +39,9 @@
|
||||
by subclassing hasMethod() and invokeMethod(), you can give your object
|
||||
methods.
|
||||
*/
|
||||
class BEAST_API DynamicObject : public ReferenceCountedObject
|
||||
class BEAST_API DynamicObject
|
||||
: public ReferenceCountedObject
|
||||
, LeakChecked <DynamicObject>
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -112,8 +114,6 @@ public:
|
||||
private:
|
||||
//==============================================================================
|
||||
NamedValueSet properties;
|
||||
|
||||
BEAST_LEAK_DETECTOR (DynamicObject)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -95,6 +95,11 @@ template <typename KeyType,
|
||||
class HashFunctionToUse = DefaultHashFunctions,
|
||||
class TypeOfCriticalSectionToUse = DummyCriticalSection>
|
||||
class HashMap
|
||||
: Uncopyable
|
||||
, LeakChecked <HashMap <KeyType,
|
||||
ValueType,
|
||||
HashFunctionToUse,
|
||||
TypeOfCriticalSectionToUse> >
|
||||
{
|
||||
private:
|
||||
typedef PARAMETER_TYPE (KeyType) KeyTypeParameter;
|
||||
@@ -333,7 +338,7 @@ public:
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
class HashEntry
|
||||
class HashEntry : Uncopyable
|
||||
{
|
||||
public:
|
||||
HashEntry (KeyTypeParameter k, ValueTypeParameter val, HashEntry* const next)
|
||||
@@ -343,8 +348,6 @@ private:
|
||||
const KeyType key;
|
||||
ValueType value;
|
||||
HashEntry* nextEntry;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (HashEntry)
|
||||
};
|
||||
|
||||
public:
|
||||
@@ -371,7 +374,7 @@ public:
|
||||
|
||||
@see HashMap
|
||||
*/
|
||||
class Iterator
|
||||
class Iterator : LeakChecked <Iterator>, Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -420,8 +423,6 @@ public:
|
||||
const HashMap& hashMap;
|
||||
HashEntry* entry;
|
||||
int index;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Iterator)
|
||||
};
|
||||
|
||||
private:
|
||||
@@ -439,8 +440,6 @@ private:
|
||||
bassert (isPositiveAndBelow (hash, getNumSlots())); // your hash function is generating out-of-range numbers!
|
||||
return hash;
|
||||
}
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HashMap)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
@endcode
|
||||
*/
|
||||
template <class ObjectType>
|
||||
class LinkedListPointer
|
||||
class LinkedListPointer : Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -330,7 +330,7 @@ public:
|
||||
list, and then repeatedly call Appender::append() to add items to the end
|
||||
of the list in O(1) time.
|
||||
*/
|
||||
class Appender
|
||||
class Appender : Uncopyable
|
||||
{
|
||||
public:
|
||||
/** Creates an appender which will add items to the given list.
|
||||
@@ -351,15 +351,11 @@ public:
|
||||
|
||||
private:
|
||||
LinkedListPointer* endOfList;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (Appender)
|
||||
};
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
ObjectType* item;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (LinkedListPointer)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ public:
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
class NamedValue
|
||||
class NamedValue : LeakChecked <NamedValue>
|
||||
{
|
||||
public:
|
||||
NamedValue() noexcept;
|
||||
@@ -151,7 +151,6 @@ private:
|
||||
var value;
|
||||
|
||||
private:
|
||||
BEAST_LEAK_DETECTOR (NamedValue)
|
||||
};
|
||||
|
||||
friend class LinkedListPointer<NamedValue>;
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
template <class ObjectClass,
|
||||
class TypeOfCriticalSectionToUse = DummyCriticalSection>
|
||||
|
||||
class OwnedArray
|
||||
class OwnedArray : LeakChecked <OwnedArray <ObjectClass, TypeOfCriticalSectionToUse> >, Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -907,8 +907,6 @@ private:
|
||||
while (numUsed > 0)
|
||||
delete data.elements [--numUsed];
|
||||
}
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OwnedArray)
|
||||
};
|
||||
|
||||
#endif // BEAST_OWNEDARRAY_BEASTHEADER
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
See the PropertiesFile class for a subclass of this, which automatically broadcasts change
|
||||
messages and saves/loads the list from a file.
|
||||
*/
|
||||
class BEAST_API PropertySet
|
||||
class BEAST_API PropertySet : LeakChecked <PropertySet>
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -206,8 +206,6 @@ private:
|
||||
PropertySet* fallbackProperties;
|
||||
CriticalSection lock;
|
||||
bool ignoreCaseOfKeys;
|
||||
|
||||
BEAST_LEAK_DETECTOR (PropertySet)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
|
||||
*/
|
||||
template <typename ValueType>
|
||||
class ScopedValueSetter
|
||||
class ScopedValueSetter : Uncopyable
|
||||
{
|
||||
public:
|
||||
/** Creates a ScopedValueSetter that will immediately change the specified value to the
|
||||
@@ -87,8 +87,6 @@ private:
|
||||
//==============================================================================
|
||||
ValueType& value;
|
||||
const ValueType originalValue;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (ScopedValueSetter)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
|
||||
#if BEAST_USE_LEAKCHECKED
|
||||
|
||||
/*============================================================================*/
|
||||
// Type-independent portion of Counter
|
||||
class LeakCheckedBase::CounterBase::Singleton
|
||||
{
|
||||
public:
|
||||
@@ -76,8 +74,18 @@ void LeakCheckedBase::CounterBase::detectLeaks ()
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
/** If you hit this, then you've leaked one or more objects of the
|
||||
specified class; the name should have been printed by the line
|
||||
below.
|
||||
|
||||
If you're leaking, it's probably because you're using old-fashioned,
|
||||
non-RAII techniques for your object management. Tut, tut. Always,
|
||||
always use ScopedPointers, OwnedArrays, ReferenceCountedObjects,
|
||||
etc, and avoid the 'delete' operator at all costs!
|
||||
*/
|
||||
DBG ("Leaked objects: " << count << " of " << getClassName ());
|
||||
|
||||
//bassertfalse;
|
||||
DBG ("[LEAK] " << count << " of " << getClassName ());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,28 +78,37 @@ class LeakChecked : private LeakCheckedBase
|
||||
protected:
|
||||
LeakChecked () noexcept
|
||||
{
|
||||
if (getLeakCheckedCounter ().increment () == 0)
|
||||
{
|
||||
DBG ("[LOGIC] " << getLeakCheckedName ());
|
||||
Throw (Error ().fail (__FILE__, __LINE__));
|
||||
}
|
||||
getCounter ().increment ();
|
||||
}
|
||||
|
||||
LeakChecked (const LeakChecked&) noexcept
|
||||
{
|
||||
if (getLeakCheckedCounter ().increment () == 0)
|
||||
{
|
||||
DBG ("[LOGIC] " << getLeakCheckedName ());
|
||||
Throw (Error ().fail (__FILE__, __LINE__));
|
||||
}
|
||||
getCounter ().increment ();
|
||||
}
|
||||
|
||||
~LeakChecked ()
|
||||
{
|
||||
if (getLeakCheckedCounter ().decrement () < 0)
|
||||
if (getCounter ().decrement () < 0)
|
||||
{
|
||||
DBG ("[LOGIC] " << getLeakCheckedName ());
|
||||
Throw (Error ().fail (__FILE__, __LINE__));
|
||||
/* If you hit this, then you've managed to delete more instances
|
||||
of this class than you've created. That indicates that you're
|
||||
deleting some dangling pointers.
|
||||
|
||||
Note that although this assertion will have been triggered
|
||||
during a destructor, it might not be this particular deletion
|
||||
that's at fault - the incorrect one may have happened at an
|
||||
earlier point in the program, and simply not been detected
|
||||
until now.
|
||||
|
||||
Most errors like this are caused by using old-fashioned,
|
||||
non-RAII techniques for your object management. Tut, tut.
|
||||
Always, always use ScopedPointers, OwnedArrays,
|
||||
ReferenceCountedObjects, etc, and avoid the 'delete' operator
|
||||
at all costs!
|
||||
*/
|
||||
DBG ("Dangling pointer deletion: " << getLeakCheckedName ());
|
||||
|
||||
bassertfalse;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,16 +139,17 @@ private:
|
||||
return typeid (Object).name ();
|
||||
}
|
||||
|
||||
static Counter& getLeakCheckedCounter () noexcept
|
||||
static Counter& getCounter () noexcept
|
||||
{
|
||||
static Counter* volatile s_instance;
|
||||
static Static::Initializer s_initializer;
|
||||
|
||||
if (s_initializer.begin ())
|
||||
if (s_initializer.beginConstruction ())
|
||||
{
|
||||
static char s_storage [sizeof (Counter)];
|
||||
s_instance = new (s_storage) Counter;
|
||||
s_initializer.end ();
|
||||
|
||||
s_initializer.endConstruction ();
|
||||
}
|
||||
|
||||
return *s_instance;
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
It can also guess how far it's got using a wildly inaccurate algorithm.
|
||||
*/
|
||||
class BEAST_API DirectoryIterator
|
||||
class BEAST_API DirectoryIterator : LeakChecked <DirectoryIterator>, Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
class NativeIterator
|
||||
class NativeIterator : LeakChecked <NativeIterator>, Uncopyable
|
||||
{
|
||||
public:
|
||||
NativeIterator (const File& directory, const String& wildCard);
|
||||
@@ -132,8 +132,6 @@ private:
|
||||
friend class DirectoryIterator;
|
||||
friend class ScopedPointer<Pimpl>;
|
||||
ScopedPointer<Pimpl> pimpl;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NativeIterator)
|
||||
};
|
||||
|
||||
friend class ScopedPointer<NativeIterator::Pimpl>;
|
||||
@@ -147,8 +145,6 @@ private:
|
||||
bool hasBeenAdvanced;
|
||||
ScopedPointer <DirectoryIterator> subIterator;
|
||||
File currentFile;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DirectoryIterator)
|
||||
};
|
||||
|
||||
#endif // BEAST_DIRECTORYITERATOR_BEASTHEADER
|
||||
|
||||
@@ -26,6 +26,15 @@ File::File (const String& fullPathName)
|
||||
{
|
||||
}
|
||||
|
||||
File::File (const File& other)
|
||||
: fullPath (other.fullPath)
|
||||
{
|
||||
}
|
||||
|
||||
File::~File() noexcept
|
||||
{
|
||||
}
|
||||
|
||||
File File::createFileWithoutCheckingPath (const String& path) noexcept
|
||||
{
|
||||
File f;
|
||||
@@ -33,11 +42,6 @@ File File::createFileWithoutCheckingPath (const String& path) noexcept
|
||||
return f;
|
||||
}
|
||||
|
||||
File::File (const File& other)
|
||||
: fullPath (other.fullPath)
|
||||
{
|
||||
}
|
||||
|
||||
File& File::operator= (const String& newPath)
|
||||
{
|
||||
fullPath = parseAbsolutePath (newPath);
|
||||
|
||||
@@ -46,7 +46,7 @@ class FileOutputStream;
|
||||
|
||||
@see FileInputStream, FileOutputStream
|
||||
*/
|
||||
class BEAST_API File
|
||||
class BEAST_API File : LeakChecked <File>
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
File (const File& other);
|
||||
|
||||
/** Destructor. */
|
||||
~File() noexcept {}
|
||||
~File() noexcept;
|
||||
|
||||
/** Sets the file based on an absolute pathname.
|
||||
|
||||
@@ -948,8 +948,6 @@ private:
|
||||
bool setFileTimesInternal (int64 m, int64 a, int64 c) const;
|
||||
void getFileTimesInternal (int64& m, int64& a, int64& c) const;
|
||||
bool setFileReadOnlyInternal (bool) const;
|
||||
|
||||
BEAST_LEAK_DETECTOR (File)
|
||||
};
|
||||
|
||||
#endif // BEAST_FILE_BEASTHEADER
|
||||
|
||||
@@ -34,7 +34,9 @@
|
||||
|
||||
@see InputStream, FileOutputStream, File::createInputStream
|
||||
*/
|
||||
class BEAST_API FileInputStream : public InputStream
|
||||
class BEAST_API FileInputStream
|
||||
: public InputStream
|
||||
, LeakChecked <FileInputStream>
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -87,8 +89,6 @@ private:
|
||||
void openHandle();
|
||||
void closeHandle();
|
||||
size_t readInternal (void* buffer, size_t numBytes);
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileInputStream)
|
||||
};
|
||||
|
||||
#endif // BEAST_FILEINPUTSTREAM_BEASTHEADER
|
||||
|
||||
@@ -34,7 +34,9 @@
|
||||
|
||||
@see OutputStream, FileInputStream, File::createOutputStream
|
||||
*/
|
||||
class BEAST_API FileOutputStream : public OutputStream
|
||||
class BEAST_API FileOutputStream
|
||||
: public OutputStream
|
||||
, LeakChecked <FileOutputStream>
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -107,8 +109,6 @@ private:
|
||||
bool flushBuffer();
|
||||
int64 setPositionInternal (int64);
|
||||
ssize_t writeInternal (const void*, size_t);
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileOutputStream)
|
||||
};
|
||||
|
||||
#endif // BEAST_FILEOUTPUTSTREAM_BEASTHEADER
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
@see File
|
||||
*/
|
||||
class BEAST_API FileSearchPath
|
||||
class BEAST_API FileSearchPath : LeakChecked <FileSearchPath>
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -157,8 +157,6 @@ private:
|
||||
StringArray directories;
|
||||
|
||||
void init (const String& path);
|
||||
|
||||
BEAST_LEAK_DETECTOR (FileSearchPath)
|
||||
};
|
||||
|
||||
#endif // BEAST_FILESEARCHPATH_BEASTHEADER
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
/**
|
||||
Maps a file into virtual memory for easy reading and/or writing.
|
||||
*/
|
||||
class BEAST_API MemoryMappedFile
|
||||
class BEAST_API MemoryMappedFile : LeakChecked <MemoryMappedFile>, Uncopyable
|
||||
{
|
||||
public:
|
||||
/** The read/write flags used when opening a memory mapped file. */
|
||||
@@ -103,8 +103,6 @@ private:
|
||||
#endif
|
||||
|
||||
void openInternal (const File&, AccessMode);
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MemoryMappedFile)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
|
||||
@see File, FileOutputStream
|
||||
*/
|
||||
class BEAST_API TemporaryFile
|
||||
class BEAST_API TemporaryFile : LeakChecked <TemporaryFile>, Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -159,8 +159,6 @@ public:
|
||||
private:
|
||||
//==============================================================================
|
||||
const File temporaryFile, targetFile;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TemporaryFile)
|
||||
};
|
||||
|
||||
#endif // BEAST_TEMPORARYFILE_BEASTHEADER
|
||||
|
||||
@@ -35,7 +35,10 @@
|
||||
|
||||
@see Logger
|
||||
*/
|
||||
class BEAST_API FileLogger : public Logger
|
||||
class BEAST_API FileLogger
|
||||
: public Logger
|
||||
, LeakChecked <FileLogger>
|
||||
, Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -126,8 +129,6 @@ private:
|
||||
CriticalSection logLock;
|
||||
|
||||
void trimFileSize (int64 maxFileSizeBytes) const;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileLogger)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ class MemoryBlock;
|
||||
Negative values are possible, but the value isn't stored as 2s-complement, so
|
||||
be careful if you use negative values and look at the values of individual bits.
|
||||
*/
|
||||
class BEAST_API BigInteger
|
||||
class BEAST_API BigInteger : LeakChecked <BigInteger>
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -312,8 +312,6 @@ private:
|
||||
void ensureSize (size_t numVals);
|
||||
void shiftLeft (int bits, int startBit);
|
||||
void shiftRight (int bits, int startBit);
|
||||
|
||||
BEAST_LEAK_DETECTOR (BigInteger)
|
||||
};
|
||||
|
||||
/** Writes a BigInteger to an OutputStream as a UTF8 decimal string. */
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
class Expression::Term : public SingleThreadedReferenceCountedObject
|
||||
class Expression::Term
|
||||
: public SingleThreadedReferenceCountedObject
|
||||
{
|
||||
public:
|
||||
Term() {}
|
||||
@@ -69,9 +70,6 @@ public:
|
||||
for (int i = getNumInputs(); --i >= 0;)
|
||||
getInput(i)->visitAllSymbols (visitor, scope, recursionDepth);
|
||||
}
|
||||
|
||||
private:
|
||||
BEAST_DECLARE_NON_COPYABLE (Term)
|
||||
};
|
||||
|
||||
|
||||
@@ -295,7 +293,8 @@ struct Expression::Helpers
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
class DotOperator : public BinaryTerm
|
||||
class DotOperator
|
||||
: public BinaryTerm
|
||||
{
|
||||
public:
|
||||
DotOperator (SymbolTerm* const l, Term* const r) : BinaryTerm (l, r) {}
|
||||
@@ -345,7 +344,9 @@ struct Expression::Helpers
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
class EvaluationVisitor : public Scope::Visitor
|
||||
class EvaluationVisitor
|
||||
: public Scope::Visitor
|
||||
, Uncopyable
|
||||
{
|
||||
public:
|
||||
EvaluationVisitor (const TermPtr& t, const int recursion)
|
||||
@@ -356,12 +357,11 @@ struct Expression::Helpers
|
||||
const TermPtr input;
|
||||
TermPtr output;
|
||||
const int recursionCount;
|
||||
|
||||
private:
|
||||
BEAST_DECLARE_NON_COPYABLE (EvaluationVisitor)
|
||||
};
|
||||
|
||||
class SymbolVisitingVisitor : public Scope::Visitor
|
||||
class SymbolVisitingVisitor
|
||||
: public Scope::Visitor
|
||||
, Uncopyable
|
||||
{
|
||||
public:
|
||||
SymbolVisitingVisitor (const TermPtr& t, SymbolVisitor& v, const int recursion)
|
||||
@@ -373,11 +373,11 @@ struct Expression::Helpers
|
||||
const TermPtr input;
|
||||
SymbolVisitor& visitor;
|
||||
const int recursionCount;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (SymbolVisitingVisitor)
|
||||
};
|
||||
|
||||
class SymbolRenamingVisitor : public Scope::Visitor
|
||||
class SymbolRenamingVisitor
|
||||
: public Scope::Visitor
|
||||
, Uncopyable
|
||||
{
|
||||
public:
|
||||
SymbolRenamingVisitor (const TermPtr& t, const Expression::Symbol& symbol_, const String& newName_, const int recursionCount_)
|
||||
@@ -390,13 +390,9 @@ struct Expression::Helpers
|
||||
const Symbol& symbol;
|
||||
const String newName;
|
||||
const int recursionCount;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (SymbolRenamingVisitor)
|
||||
};
|
||||
|
||||
SymbolTerm* getSymbol() const { return static_cast <SymbolTerm*> (left.get()); }
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (DotOperator)
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
@@ -446,7 +442,7 @@ struct Expression::Helpers
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
class Add : public BinaryTerm
|
||||
class Add : public BinaryTerm
|
||||
{
|
||||
public:
|
||||
Add (Term* const l, Term* const r) : BinaryTerm (l, r) {}
|
||||
@@ -465,13 +461,10 @@ struct Expression::Helpers
|
||||
|
||||
return new Subtract (newDest, (input == left ? right : left)->clone());
|
||||
}
|
||||
|
||||
private:
|
||||
BEAST_DECLARE_NON_COPYABLE (Add)
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
class Subtract : public BinaryTerm
|
||||
class Subtract : public BinaryTerm
|
||||
{
|
||||
public:
|
||||
Subtract (Term* const l, Term* const r) : BinaryTerm (l, r) {}
|
||||
@@ -493,13 +486,10 @@ struct Expression::Helpers
|
||||
|
||||
return new Subtract (left->clone(), newDest);
|
||||
}
|
||||
|
||||
private:
|
||||
BEAST_DECLARE_NON_COPYABLE (Subtract)
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
class Multiply : public BinaryTerm
|
||||
class Multiply : public BinaryTerm
|
||||
{
|
||||
public:
|
||||
Multiply (Term* const l, Term* const r) : BinaryTerm (l, r) {}
|
||||
@@ -518,13 +508,10 @@ struct Expression::Helpers
|
||||
|
||||
return new Divide (newDest, (input == left ? right : left)->clone());
|
||||
}
|
||||
|
||||
private:
|
||||
BEAST_DECLARE_NON_COPYABLE (Multiply)
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
class Divide : public BinaryTerm
|
||||
class Divide : public BinaryTerm
|
||||
{
|
||||
public:
|
||||
Divide (Term* const l, Term* const r) : BinaryTerm (l, r) {}
|
||||
@@ -546,9 +533,6 @@ struct Expression::Helpers
|
||||
|
||||
return new Divide (left->clone(), newDest);
|
||||
}
|
||||
|
||||
private:
|
||||
BEAST_DECLARE_NON_COPYABLE (Divide)
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
@@ -621,7 +605,9 @@ struct Expression::Helpers
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
class SymbolCheckVisitor : public Term::SymbolVisitor
|
||||
class SymbolCheckVisitor
|
||||
: public Term::SymbolVisitor
|
||||
, Uncopyable
|
||||
{
|
||||
public:
|
||||
SymbolCheckVisitor (const Symbol& symbol_) : wasFound (false), symbol (symbol_) {}
|
||||
@@ -631,12 +617,12 @@ struct Expression::Helpers
|
||||
|
||||
private:
|
||||
const Symbol& symbol;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (SymbolCheckVisitor)
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
class SymbolListVisitor : public Term::SymbolVisitor
|
||||
class SymbolListVisitor
|
||||
: public Term::SymbolVisitor
|
||||
, Uncopyable
|
||||
{
|
||||
public:
|
||||
SymbolListVisitor (Array<Symbol>& list_) : list (list_) {}
|
||||
@@ -644,12 +630,10 @@ struct Expression::Helpers
|
||||
|
||||
private:
|
||||
Array<Symbol>& list;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (SymbolListVisitor)
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
class Parser
|
||||
class Parser : Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -908,8 +892,6 @@ struct Expression::Helpers
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (Parser)
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
You can create a Random object and use it to generate a sequence of random numbers.
|
||||
*/
|
||||
class BEAST_API Random
|
||||
class BEAST_API Random : LeakChecked <Random>
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -127,8 +127,6 @@ public:
|
||||
private:
|
||||
//==============================================================================
|
||||
int64 seed;
|
||||
|
||||
BEAST_LEAK_DETECTOR (Random)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
/** Contains static methods for converting the byte order between different
|
||||
endiannesses.
|
||||
*/
|
||||
class BEAST_API ByteOrder
|
||||
class BEAST_API ByteOrder : Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -93,8 +93,6 @@ public:
|
||||
|
||||
private:
|
||||
ByteOrder();
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (ByteOrder)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace HeapBlockHelper
|
||||
@see Array, OwnedArray, MemoryBlock
|
||||
*/
|
||||
template <class ElementType, bool throwOnFailure = false>
|
||||
class HeapBlock
|
||||
class HeapBlock : Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -294,7 +294,6 @@ private:
|
||||
}
|
||||
|
||||
#if ! (defined (BEAST_DLL) || defined (BEAST_DLL_BUILD))
|
||||
BEAST_DECLARE_NON_COPYABLE (HeapBlock)
|
||||
BEAST_PREVENT_HEAP_ALLOCATION // Creating a 'new HeapBlock' would be missing the point!
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -1,144 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Portions of this file are from JUCE.
|
||||
Copyright (c) 2013 - Raw Material Software Ltd.
|
||||
Please visit http://www.juce.com
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_LEAKEDOBJECTDETECTOR_BEASTHEADER
|
||||
#define BEAST_LEAKEDOBJECTDETECTOR_BEASTHEADER
|
||||
|
||||
#include "../text/beast_String.h"
|
||||
#include "beast_Atomic.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
Embedding an instance of this class inside another class can be used as a low-overhead
|
||||
way of detecting leaked instances.
|
||||
|
||||
This class keeps an internal static count of the number of instances that are
|
||||
active, so that when the app is shutdown and the static destructors are called,
|
||||
it can check whether there are any left-over instances that may have been leaked.
|
||||
|
||||
To use it, use the BEAST_LEAK_DETECTOR macro as a simple way to put one in your
|
||||
class declaration. Have a look through the beast codebase for examples, it's used
|
||||
in most of the classes.
|
||||
*/
|
||||
template <class OwnerClass>
|
||||
class LeakedObjectDetector
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
LeakedObjectDetector() noexcept { ++(getCounter().numObjects); }
|
||||
LeakedObjectDetector (const LeakedObjectDetector&) noexcept { ++(getCounter().numObjects); }
|
||||
|
||||
~LeakedObjectDetector()
|
||||
{
|
||||
if (--(getCounter().numObjects) < 0)
|
||||
{
|
||||
DBG ("*** Dangling pointer deletion! Class: " << getLeakedObjectClassName());
|
||||
|
||||
/** If you hit this, then you've managed to delete more instances of this class than you've
|
||||
created.. That indicates that you're deleting some dangling pointers.
|
||||
|
||||
Note that although this assertion will have been triggered during a destructor, it might
|
||||
not be this particular deletion that's at fault - the incorrect one may have happened
|
||||
at an earlier point in the program, and simply not been detected until now.
|
||||
|
||||
Most errors like this are caused by using old-fashioned, non-RAII techniques for
|
||||
your object management. Tut, tut. Always, always use ScopedPointers, OwnedArrays,
|
||||
ReferenceCountedObjects, etc, and avoid the 'delete' operator at all costs!
|
||||
*/
|
||||
bassertfalse;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
class LeakCounter
|
||||
{
|
||||
public:
|
||||
LeakCounter() noexcept {}
|
||||
|
||||
~LeakCounter()
|
||||
{
|
||||
if (numObjects.value > 0)
|
||||
{
|
||||
DBG ("*** Leaked objects detected: " << numObjects.value << " instance(s) of class " << getLeakedObjectClassName());
|
||||
|
||||
/** If you hit this, then you've leaked one or more objects of the type specified by
|
||||
the 'OwnerClass' template parameter - the name should have been printed by the line above.
|
||||
|
||||
If you're leaking, it's probably because you're using old-fashioned, non-RAII techniques for
|
||||
your object management. Tut, tut. Always, always use ScopedPointers, OwnedArrays,
|
||||
ReferenceCountedObjects, etc, and avoid the 'delete' operator at all costs!
|
||||
*/
|
||||
//bassertfalse;
|
||||
}
|
||||
}
|
||||
|
||||
Atomic<int> numObjects;
|
||||
};
|
||||
|
||||
static const char* getLeakedObjectClassName()
|
||||
{
|
||||
return OwnerClass::getLeakedObjectClassName();
|
||||
}
|
||||
|
||||
static LeakCounter& getCounter() noexcept
|
||||
{
|
||||
static LeakCounter counter;
|
||||
return counter;
|
||||
}
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
#if DOXYGEN || ! defined (BEAST_LEAK_DETECTOR)
|
||||
#if (DOXYGEN || BEAST_CHECK_MEMORY_LEAKS)
|
||||
/** This macro lets you embed a leak-detecting object inside a class.
|
||||
|
||||
To use it, simply declare a BEAST_LEAK_DETECTOR(YourClassName) inside a private section
|
||||
of the class declaration. E.g.
|
||||
|
||||
@code
|
||||
class MyClass
|
||||
{
|
||||
public:
|
||||
MyClass();
|
||||
void blahBlah();
|
||||
|
||||
private:
|
||||
BEAST_LEAK_DETECTOR (MyClass)
|
||||
};
|
||||
@endcode
|
||||
|
||||
@see BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR, LeakedObjectDetector
|
||||
*/
|
||||
#define BEAST_LEAK_DETECTOR(OwnerClass) \
|
||||
friend class beast::LeakedObjectDetector<OwnerClass>; \
|
||||
static const char* getLeakedObjectClassName() noexcept { return #OwnerClass; } \
|
||||
beast::LeakedObjectDetector<OwnerClass> BEAST_JOIN_MACRO (leakDetector, __LINE__);
|
||||
#else
|
||||
#define BEAST_LEAK_DETECTOR(OwnerClass)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif // BEAST_LEAKEDOBJECTDETECTOR_BEASTHEADER
|
||||
@@ -65,7 +65,7 @@ inline Type* createCopyIfNotNull (const Type* pointer) { return pointer != n
|
||||
/** A handy C++ wrapper that creates and deletes an NSAutoreleasePool object using RAII.
|
||||
You should use the BEAST_AUTORELEASEPOOL macro to create a local auto-release pool on the stack.
|
||||
*/
|
||||
class BEAST_API ScopedAutoReleasePool
|
||||
class BEAST_API ScopedAutoReleasePool : Uncopyable
|
||||
{
|
||||
public:
|
||||
ScopedAutoReleasePool();
|
||||
@@ -73,8 +73,6 @@ inline Type* createCopyIfNotNull (const Type* pointer) { return pointer != n
|
||||
|
||||
private:
|
||||
void* pool;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (ScopedAutoReleasePool)
|
||||
};
|
||||
|
||||
/** A macro that can be used to easily declare a local ScopedAutoReleasePool
|
||||
@@ -92,30 +90,5 @@ inline Type* createCopyIfNotNull (const Type* pointer) { return pointer != n
|
||||
#define BEAST_AUTORELEASEPOOL
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
/* In a Windows DLL build, we'll expose some malloc/free functions that live inside the DLL, and use these for
|
||||
allocating all the objects - that way all beast objects in the DLL and in the host will live in the same heap,
|
||||
avoiding problems when an object is created in one module and passed across to another where it is deleted.
|
||||
By piggy-backing on the BEAST_LEAK_DETECTOR macro, these allocators can be injected into most beast classes.
|
||||
*/
|
||||
#if BEAST_MSVC && (defined (BEAST_DLL) || defined (BEAST_DLL_BUILD)) && ! (BEAST_DISABLE_DLL_ALLOCATORS || DOXYGEN)
|
||||
extern BEAST_API void* beastDLL_malloc (size_t);
|
||||
extern BEAST_API void beastDLL_free (void*);
|
||||
|
||||
#define BEAST_LEAK_DETECTOR(OwnerClass) public:\
|
||||
static void* operator new (size_t sz) { return beast::beastDLL_malloc (sz); } \
|
||||
static void* operator new (size_t, void* p) { return p; } \
|
||||
static void operator delete (void* p) { beast::beastDLL_free (p); } \
|
||||
static void operator delete (void*, void*) {}
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
/** (Deprecated) This was a Windows-specific way of checking for object leaks - now please
|
||||
use the BEAST_LEAK_DETECTOR instead.
|
||||
*/
|
||||
#ifndef beast_UseDebuggingNewOperator
|
||||
#define beast_UseDebuggingNewOperator
|
||||
#endif
|
||||
|
||||
|
||||
#endif // BEAST_MEMORY_BEASTHEADER
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
A class to hold a resizable block of raw data.
|
||||
|
||||
*/
|
||||
class BEAST_API MemoryBlock
|
||||
class BEAST_API MemoryBlock : LeakChecked <MemoryBlock>
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -247,8 +247,6 @@ private:
|
||||
HeapBlock <char> data;
|
||||
size_t size;
|
||||
static const char* const encodingTable;
|
||||
|
||||
BEAST_LEAK_DETECTOR (MemoryBlock)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
|
||||
@see ReferenceCountedObjectPtr, ReferenceCountedArray, SingleThreadedReferenceCountedObject
|
||||
*/
|
||||
class BEAST_API ReferenceCountedObject
|
||||
class BEAST_API ReferenceCountedObject : Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -114,8 +114,6 @@ protected:
|
||||
private:
|
||||
//==============================================================================
|
||||
Atomic <int> refCount;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (ReferenceCountedObject)
|
||||
};
|
||||
|
||||
|
||||
@@ -130,7 +128,7 @@ private:
|
||||
|
||||
@see ReferenceCountedObject, ReferenceCountedObjectPtr, ReferenceCountedArray
|
||||
*/
|
||||
class BEAST_API SingleThreadedReferenceCountedObject
|
||||
class BEAST_API SingleThreadedReferenceCountedObject : public Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -175,8 +173,6 @@ protected:
|
||||
private:
|
||||
//==============================================================================
|
||||
int refCount;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (SingleThreadedReferenceCountedObject)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
you'd need to return a raw pointer (or use a std::auto_ptr instead).
|
||||
*/
|
||||
template <class ObjectType>
|
||||
class ScopedPointer
|
||||
class ScopedPointer : Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -215,7 +215,6 @@ private:
|
||||
It's probably best to use the latter form when writing your object declarations anyway, as
|
||||
this is a better representation of the code that you actually want the compiler to produce.
|
||||
*/
|
||||
BEAST_DECLARE_NON_COPYABLE (ScopedPointer)
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -120,26 +120,19 @@ char Storage <ObjectType, Tag>::s_storage [sizeof (ObjectType)];
|
||||
class Initializer
|
||||
{
|
||||
public:
|
||||
/*
|
||||
bool inited () const
|
||||
{
|
||||
return m_state.get () == stateInitialized;
|
||||
}
|
||||
*/
|
||||
|
||||
// If the condition is not initialized, the first caller will
|
||||
// receive true, while concurrent callers get blocked until
|
||||
// initialization completes.
|
||||
//
|
||||
bool begin ()
|
||||
bool beginConstruction ()
|
||||
{
|
||||
bool shouldInitialize;
|
||||
bool needsInitialization = false;
|
||||
|
||||
if (m_state.get () == stateUninitialized)
|
||||
if (m_state.get () != stateInitialized)
|
||||
{
|
||||
if (m_state.compareAndSetBool (stateInitializing, stateUninitialized))
|
||||
{
|
||||
shouldInitialize = true;
|
||||
needsInitialization = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -150,21 +143,15 @@ public:
|
||||
delay.pause ();
|
||||
}
|
||||
while (m_state.get () != stateInitialized);
|
||||
|
||||
shouldInitialize = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
shouldInitialize = false;
|
||||
}
|
||||
|
||||
return shouldInitialize;
|
||||
return needsInitialization;
|
||||
}
|
||||
|
||||
// Called to signal that the initialization is complete
|
||||
//
|
||||
void end ()
|
||||
void endConstruction ()
|
||||
{
|
||||
m_state.set (stateInitialized);
|
||||
}
|
||||
|
||||
@@ -20,10 +20,39 @@
|
||||
#ifndef BEAST_UNCOPYABLE_BEASTHEADER
|
||||
#define BEAST_UNCOPYABLE_BEASTHEADER
|
||||
|
||||
// Prevents warnings about missing copy
|
||||
// constructors and assignment operators.
|
||||
/** Prevent copy construction and assignment.
|
||||
|
||||
// Ideas based on boost
|
||||
This is used to suppress warnings and prevent unsafe operations on
|
||||
objects which cannot be passed by value. Ideas based on Boost.
|
||||
|
||||
For example, instead of
|
||||
|
||||
@code
|
||||
|
||||
class MyClass
|
||||
{
|
||||
public:
|
||||
//...
|
||||
|
||||
private:
|
||||
MyClass (const MyClass&);
|
||||
MyClass& operator= (const MyClass&);
|
||||
};
|
||||
|
||||
@endcode
|
||||
|
||||
..you can just write:
|
||||
|
||||
@code
|
||||
|
||||
class MyClass : Uncopyable
|
||||
{
|
||||
public:
|
||||
//...
|
||||
};
|
||||
|
||||
@endcode
|
||||
*/
|
||||
class Uncopyable
|
||||
{
|
||||
protected:
|
||||
|
||||
@@ -128,7 +128,9 @@ public:
|
||||
in your code!
|
||||
@see WeakReference
|
||||
*/
|
||||
class SharedPointer : public ReferenceCountingType
|
||||
class SharedPointer
|
||||
: public ReferenceCountingType
|
||||
, Uncopyable
|
||||
{
|
||||
public:
|
||||
explicit SharedPointer (ObjectType* const obj) noexcept : owner (obj) {}
|
||||
@@ -138,8 +140,6 @@ public:
|
||||
|
||||
private:
|
||||
ObjectType* volatile owner;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (SharedPointer)
|
||||
};
|
||||
|
||||
typedef ReferenceCountedObjectPtr<SharedPointer> SharedRef;
|
||||
@@ -150,7 +150,7 @@ public:
|
||||
See the WeakReference class notes for an example of how to use this class.
|
||||
@see WeakReference
|
||||
*/
|
||||
class Master
|
||||
class Master : Uncopyable
|
||||
{
|
||||
public:
|
||||
Master() noexcept {}
|
||||
@@ -192,8 +192,6 @@ public:
|
||||
|
||||
private:
|
||||
SharedRef sharedPointer;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (Master)
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
The class includes methods for saving the ID as a string or as raw binary data.
|
||||
*/
|
||||
class BEAST_API Uuid
|
||||
class BEAST_API Uuid : LeakChecked <Uuid>
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -101,8 +101,6 @@ public:
|
||||
private:
|
||||
//==============================================================================
|
||||
uint8 uuid[16];
|
||||
|
||||
BEAST_LEAK_DETECTOR (Uuid)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
Contains some static helper functions for manipulating the MS Windows registry
|
||||
(Only available on Windows, of course!)
|
||||
*/
|
||||
class WindowsRegistry
|
||||
class WindowsRegistry : Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -112,7 +112,6 @@ public:
|
||||
|
||||
private:
|
||||
WindowsRegistry();
|
||||
BEAST_DECLARE_NON_COPYABLE (WindowsRegistry)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -148,7 +148,7 @@ bool File::moveToTrash() const
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
class DirectoryIterator::NativeIterator::Pimpl
|
||||
class DirectoryIterator::NativeIterator::Pimpl : Uncopyable
|
||||
{
|
||||
public:
|
||||
Pimpl (const File& directory, const String& wildCard_)
|
||||
@@ -202,8 +202,6 @@ public:
|
||||
private:
|
||||
String parentDir, wildCard;
|
||||
DIR* dir;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (Pimpl)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
class JNIClassBase
|
||||
class JNIClassBase : Uncopyable
|
||||
{
|
||||
public:
|
||||
explicit JNIClassBase (const char* classPath);
|
||||
@@ -193,8 +193,6 @@ private:
|
||||
static Array<JNIClassBase*>& getClasses();
|
||||
void initialise (JNIEnv*);
|
||||
void release (JNIEnv*);
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (JNIClassBase)
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
||||
@@ -60,7 +60,10 @@ bool Process::openEmailWithAttachments (const String& targetEmailAddress,
|
||||
|
||||
|
||||
//==============================================================================
|
||||
class WebInputStream : public InputStream
|
||||
class WebInputStream
|
||||
: public InputStream
|
||||
, LeakChecked <WebInputStream>
|
||||
, Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -154,9 +157,6 @@ public:
|
||||
|
||||
//==============================================================================
|
||||
GlobalRef stream;
|
||||
|
||||
private:
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WebInputStream)
|
||||
};
|
||||
|
||||
InputStream* URL::createNativeStream (const String& address, bool isPost, const MemoryBlock& postData,
|
||||
|
||||
@@ -241,7 +241,7 @@ bool File::moveToTrash() const
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
class DirectoryIterator::NativeIterator::Pimpl
|
||||
class DirectoryIterator::NativeIterator::Pimpl : Uncopyable
|
||||
{
|
||||
public:
|
||||
Pimpl (const File& directory, const String& wildCard_)
|
||||
@@ -295,8 +295,6 @@ public:
|
||||
private:
|
||||
String parentDir, wildCard;
|
||||
DIR* dir;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (Pimpl)
|
||||
};
|
||||
|
||||
DirectoryIterator::NativeIterator::NativeIterator (const File& directory, const String& wildCard)
|
||||
|
||||
@@ -60,7 +60,9 @@ bool Process::openEmailWithAttachments (const String& /* targetEmailAddress */,
|
||||
|
||||
|
||||
//==============================================================================
|
||||
class WebInputStream : public InputStream
|
||||
class WebInputStream
|
||||
: public InputStream
|
||||
, LeakChecked <WebInputStream>
|
||||
{
|
||||
public:
|
||||
WebInputStream (const String& address_, bool isPost_, const MemoryBlock& postData_,
|
||||
@@ -439,8 +441,6 @@ private:
|
||||
|
||||
return String::empty;
|
||||
}
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WebInputStream)
|
||||
};
|
||||
|
||||
InputStream* URL::createNativeStream (const String& address, bool isPost, const MemoryBlock& postData,
|
||||
|
||||
@@ -241,7 +241,7 @@ bool File::moveToTrash() const
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
class DirectoryIterator::NativeIterator::Pimpl
|
||||
class DirectoryIterator::NativeIterator::Pimpl : Uncopyable
|
||||
{
|
||||
public:
|
||||
Pimpl (const File& directory, const String& wildCard_)
|
||||
@@ -295,8 +295,6 @@ public:
|
||||
private:
|
||||
String parentDir, wildCard;
|
||||
DIR* dir;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (Pimpl)
|
||||
};
|
||||
|
||||
DirectoryIterator::NativeIterator::NativeIterator (const File& directory, const String& wildCard)
|
||||
|
||||
@@ -62,7 +62,10 @@ bool Process::openEmailWithAttachments (const String& /* targetEmailAddress */,
|
||||
|
||||
|
||||
//==============================================================================
|
||||
class WebInputStream : public InputStream
|
||||
class WebInputStream
|
||||
: public InputStream
|
||||
, LeakChecked <WebInputStream>
|
||||
, Uncopyable
|
||||
{
|
||||
public:
|
||||
WebInputStream (const String& address_, bool isPost_, const MemoryBlock& postData_,
|
||||
@@ -441,8 +444,6 @@ private:
|
||||
|
||||
return String::empty;
|
||||
}
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WebInputStream)
|
||||
};
|
||||
|
||||
InputStream* URL::createNativeStream (const String& address, bool isPost, const MemoryBlock& postData,
|
||||
|
||||
@@ -308,7 +308,7 @@ bool File::moveToTrash() const
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
class DirectoryIterator::NativeIterator::Pimpl
|
||||
class DirectoryIterator::NativeIterator::Pimpl : Uncopyable
|
||||
{
|
||||
public:
|
||||
Pimpl (const File& directory, const String& wildCard_)
|
||||
@@ -364,8 +364,6 @@ public:
|
||||
private:
|
||||
String parentDir, wildCard;
|
||||
NSDirectoryEnumerator* enumerator;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (Pimpl)
|
||||
};
|
||||
|
||||
DirectoryIterator::NativeIterator::NativeIterator (const File& directory, const String& wildcard)
|
||||
|
||||
@@ -97,7 +97,10 @@ bool Process::openEmailWithAttachments (const String& targetEmailAddress,
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
class URLConnectionState : public Thread
|
||||
class URLConnectionState
|
||||
: public Thread
|
||||
, LeakChecked <URLConnectionState>
|
||||
, Uncopyable
|
||||
{
|
||||
public:
|
||||
URLConnectionState (NSURLRequest* req)
|
||||
@@ -290,13 +293,14 @@ private:
|
||||
getState (self)->finishedLoading();
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (URLConnectionState)
|
||||
};
|
||||
|
||||
|
||||
//==============================================================================
|
||||
class WebInputStream : public InputStream
|
||||
class WebInputStream
|
||||
: public InputStream
|
||||
, LeakChecked <WebInputStream>
|
||||
, Uncopyable
|
||||
{
|
||||
public:
|
||||
WebInputStream (const String& address_, bool isPost_, const MemoryBlock& postData_,
|
||||
@@ -411,8 +415,6 @@ private:
|
||||
connection = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WebInputStream)
|
||||
};
|
||||
|
||||
InputStream* URL::createNativeStream (const String& address, bool isPost, const MemoryBlock& postData,
|
||||
|
||||
@@ -64,7 +64,7 @@ struct NSObjectRetainer
|
||||
|
||||
//==============================================================================
|
||||
template <typename SuperclassType>
|
||||
struct ObjCClass
|
||||
struct ObjCClass : Uncopyable
|
||||
{
|
||||
ObjCClass (const char* nameRoot)
|
||||
: cls (objc_allocateClassPair ([SuperclassType class], getRandomisedName (nameRoot).toUTF8(), 0))
|
||||
@@ -145,8 +145,6 @@ private:
|
||||
{
|
||||
return root + String::toHexString (beast::Random::getSystemRandom().nextInt64());
|
||||
}
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (ObjCClass)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
class NamedPipe::Pimpl
|
||||
class NamedPipe::Pimpl : LeakChecked <Pimpl>, Uncopyable
|
||||
{
|
||||
public:
|
||||
Pimpl (const String& pipePath, bool createPipe)
|
||||
@@ -164,8 +164,6 @@ private:
|
||||
|
||||
select (handle + 1, &rset, nullptr, 0, &timeout);
|
||||
}
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Pimpl)
|
||||
};
|
||||
|
||||
void NamedPipe::close()
|
||||
|
||||
@@ -973,7 +973,7 @@ void* DynamicLibrary::getFunction (const String& functionName) noexcept
|
||||
|
||||
|
||||
//==============================================================================
|
||||
class ChildProcess::ActiveProcess
|
||||
class ChildProcess::ActiveProcess : LeakChecked <ActiveProcess>, Uncopyable
|
||||
{
|
||||
public:
|
||||
ActiveProcess (const StringArray& arguments)
|
||||
@@ -1066,8 +1066,6 @@ public:
|
||||
private:
|
||||
int pipeHandle;
|
||||
FILE* readHandle;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ActiveProcess)
|
||||
};
|
||||
|
||||
bool ChildProcess::start (const String& command)
|
||||
@@ -1104,7 +1102,7 @@ bool ChildProcess::kill()
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
struct HighResolutionTimer::Pimpl
|
||||
struct HighResolutionTimer::Pimpl : Uncopyable
|
||||
{
|
||||
Pimpl (HighResolutionTimer& t) : owner (t), thread (0), shouldStop (false)
|
||||
{
|
||||
@@ -1250,6 +1248,4 @@ private:
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (Pimpl)
|
||||
};
|
||||
|
||||
@@ -628,6 +628,8 @@ bool File::createLink (const String& description, const File& linkFileToCreate)
|
||||
|
||||
//==============================================================================
|
||||
class DirectoryIterator::NativeIterator::Pimpl
|
||||
: LeakChecked <DirectoryIterator::NativeIterator::Pimpl>
|
||||
, Uncopyable
|
||||
{
|
||||
public:
|
||||
Pimpl (const File& directory, const String& wildCard)
|
||||
@@ -677,8 +679,6 @@ public:
|
||||
private:
|
||||
const String directoryWithWildCard;
|
||||
HANDLE handle;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Pimpl)
|
||||
};
|
||||
|
||||
DirectoryIterator::NativeIterator::NativeIterator (const File& directory, const String& wildCard)
|
||||
@@ -731,7 +731,7 @@ void File::revealToUser() const
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
class NamedPipe::Pimpl
|
||||
class NamedPipe::Pimpl : LeakChecked <NamedPipe::Pimpl>, Uncopyable
|
||||
{
|
||||
public:
|
||||
Pimpl (const String& pipeName, const bool createPipe)
|
||||
@@ -914,8 +914,6 @@ private:
|
||||
CancelIo (pipeH);
|
||||
return false;
|
||||
}
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Pimpl)
|
||||
};
|
||||
|
||||
void NamedPipe::close()
|
||||
|
||||
@@ -30,7 +30,9 @@
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
class WebInputStream : public InputStream
|
||||
class WebInputStream
|
||||
: public InputStream
|
||||
, LeakChecked <WebInputStream>
|
||||
{
|
||||
public:
|
||||
WebInputStream (const String& address_, bool isPost_, const MemoryBlock& postData_,
|
||||
@@ -296,8 +298,6 @@ private:
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WebInputStream)
|
||||
};
|
||||
|
||||
InputStream* URL::createNativeStream (const String& address, bool isPost, const MemoryBlock& postData,
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
struct RegistryKeyWrapper
|
||||
struct RegistryKeyWrapper : Uncopyable
|
||||
{
|
||||
RegistryKeyWrapper (String name, const bool createForWriting, const DWORD wow64Flags)
|
||||
: key (0), wideCharValueName (nullptr)
|
||||
@@ -130,8 +130,6 @@ struct RegistryKeyWrapper
|
||||
HKEY key;
|
||||
const wchar_t* wideCharValueName;
|
||||
String valueName;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (RegistryKeyWrapper)
|
||||
};
|
||||
|
||||
uint32 WindowsRegistry::getBinaryValue (const String& regValuePath, MemoryBlock& result)
|
||||
|
||||
@@ -459,7 +459,7 @@ void InterProcessLock::exit()
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
class ChildProcess::ActiveProcess
|
||||
class ChildProcess::ActiveProcess : LeakChecked <ChildProcess::ActiveProcess>, Uncopyable
|
||||
{
|
||||
public:
|
||||
ActiveProcess (const String& command)
|
||||
@@ -549,8 +549,6 @@ public:
|
||||
private:
|
||||
HANDLE readPipe, writePipe;
|
||||
PROCESS_INFORMATION processInfo;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ActiveProcess)
|
||||
};
|
||||
|
||||
bool ChildProcess::start (const String& command)
|
||||
@@ -584,7 +582,7 @@ bool ChildProcess::kill()
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
struct HighResolutionTimer::Pimpl
|
||||
struct HighResolutionTimer::Pimpl : Uncopyable
|
||||
{
|
||||
Pimpl (HighResolutionTimer& t) noexcept : owner (t), periodMs (0)
|
||||
{
|
||||
@@ -631,6 +629,4 @@ private:
|
||||
if (timer->periodMs != 0)
|
||||
timer->owner.hiResTimerCallback();
|
||||
}
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (Pimpl)
|
||||
};
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
@see InterprocessConnection
|
||||
*/
|
||||
class BEAST_API NamedPipe
|
||||
class BEAST_API NamedPipe : LeakChecked <NamedPipe>, Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -92,8 +92,6 @@ private:
|
||||
ReadWriteLock lock;
|
||||
|
||||
bool openInternal (const String& pipeName, const bool createPipe);
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NamedPipe)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
@see DatagramSocket, InterprocessConnection, InterprocessConnectionServer
|
||||
*/
|
||||
class BEAST_API StreamingSocket
|
||||
class BEAST_API StreamingSocket : LeakChecked <StreamingSocket>, Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -163,8 +163,6 @@ private:
|
||||
bool connected, isListener;
|
||||
|
||||
StreamingSocket (const String& hostname, int portNumber, int handle);
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StreamingSocket)
|
||||
};
|
||||
|
||||
|
||||
@@ -177,7 +175,7 @@ private:
|
||||
|
||||
@see StreamingSocket, InterprocessConnection, InterprocessConnectionServer
|
||||
*/
|
||||
class BEAST_API DatagramSocket
|
||||
class BEAST_API DatagramSocket : LeakChecked <DatagramSocket>, Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -294,8 +292,6 @@ private:
|
||||
void* serverAddress;
|
||||
|
||||
DatagramSocket (const String& hostname, int portNumber, int handle, int localPortNumber);
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DatagramSocket)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class XmlElement;
|
||||
This class can be used to launch URLs in browsers, and also to create
|
||||
InputStreams that can read from remote http or ftp sources.
|
||||
*/
|
||||
class BEAST_API URL
|
||||
class BEAST_API URL : LeakChecked <URL>
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -338,7 +338,6 @@ private:
|
||||
OpenStreamProgressCallback* progressCallback,
|
||||
void* progressCallbackContext, const String& headers,
|
||||
const int timeOutMs, StringPairArray* responseHeaders);
|
||||
BEAST_LEAK_DETECTOR (URL)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -37,7 +37,9 @@
|
||||
so that the source stream gets accessed in larger chunk sizes, meaning less
|
||||
work for the underlying stream.
|
||||
*/
|
||||
class BEAST_API BufferedInputStream : public InputStream
|
||||
class BEAST_API BufferedInputStream
|
||||
: public InputStream
|
||||
, LeakChecked <BufferedInputStream>
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -84,8 +86,6 @@ private:
|
||||
int64 position, lastReadPos, bufferStart, bufferOverlap;
|
||||
HeapBlock <char> buffer;
|
||||
void ensureBuffered();
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BufferedInputStream)
|
||||
};
|
||||
|
||||
#endif // BEAST_BUFFEREDINPUTSTREAM_BEASTHEADER
|
||||
|
||||
@@ -34,7 +34,10 @@
|
||||
|
||||
@see InputSource
|
||||
*/
|
||||
class BEAST_API FileInputSource : public InputSource
|
||||
class BEAST_API FileInputSource
|
||||
: public InputSource
|
||||
, LeakChecked <FileInputSource>
|
||||
, Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -56,8 +59,6 @@ private:
|
||||
//==============================================================================
|
||||
const File file;
|
||||
bool useFileTimeInHashGeneration;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileInputSource)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
@see FileInputSource
|
||||
*/
|
||||
class BEAST_API InputSource
|
||||
class BEAST_API InputSource : LeakChecked <InputSource>
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -63,11 +63,6 @@ public:
|
||||
/** Returns a hash code that uniquely represents this item.
|
||||
*/
|
||||
virtual int64 hashCode() const = 0;
|
||||
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
BEAST_LEAK_DETECTOR (InputSource)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ class MemoryBlock;
|
||||
@see OutputStream, MemoryInputStream, BufferedInputStream, FileInputStream
|
||||
*/
|
||||
class BEAST_API InputStream
|
||||
: public Uncopyable
|
||||
, LeakChecked <InputStream>
|
||||
{
|
||||
public:
|
||||
/** Destructor. */
|
||||
@@ -285,9 +287,6 @@ public:
|
||||
protected:
|
||||
//==============================================================================
|
||||
InputStream() noexcept {}
|
||||
|
||||
private:
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (InputStream)
|
||||
};
|
||||
|
||||
#endif // BEAST_INPUTSTREAM_BEASTHEADER
|
||||
|
||||
@@ -35,7 +35,9 @@
|
||||
This can either be used to refer to a shared block of memory, or can make its
|
||||
own internal copy of the data when the MemoryInputStream is created.
|
||||
*/
|
||||
class BEAST_API MemoryInputStream : public InputStream
|
||||
class BEAST_API MemoryInputStream
|
||||
: public InputStream
|
||||
, LeakChecked <MemoryInputStream>
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -88,8 +90,6 @@ private:
|
||||
HeapBlock<char> internalCopy;
|
||||
|
||||
void createInternalCopy();
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MemoryInputStream)
|
||||
};
|
||||
|
||||
#endif // BEAST_MEMORYINPUTSTREAM_BEASTHEADER
|
||||
|
||||
@@ -36,7 +36,9 @@
|
||||
The data that was written into the stream can then be accessed later as
|
||||
a contiguous block of memory.
|
||||
*/
|
||||
class BEAST_API MemoryOutputStream : public OutputStream
|
||||
class BEAST_API MemoryOutputStream
|
||||
: public OutputStream
|
||||
, LeakChecked <MemoryOutputStream>
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -120,8 +122,6 @@ private:
|
||||
|
||||
void trimExternalBlockSize();
|
||||
char* prepareToWrite (size_t);
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MemoryOutputStream)
|
||||
};
|
||||
|
||||
/** Copies all the data that has been written to a MemoryOutputStream into another stream. */
|
||||
|
||||
@@ -41,6 +41,8 @@ class File;
|
||||
@see InputStream, MemoryOutputStream, FileOutputStream
|
||||
*/
|
||||
class BEAST_API OutputStream
|
||||
: public Uncopyable
|
||||
, LeakChecked <OutputStream>
|
||||
{
|
||||
protected:
|
||||
//==============================================================================
|
||||
@@ -220,8 +222,6 @@ public:
|
||||
private:
|
||||
//==============================================================================
|
||||
String newLineString;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OutputStream)
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
||||
@@ -34,7 +34,9 @@
|
||||
This lets you take a subsection of a stream and present it as an entire
|
||||
stream in its own right.
|
||||
*/
|
||||
class BEAST_API SubregionStream : public InputStream
|
||||
class BEAST_API SubregionStream
|
||||
: public InputStream
|
||||
, LeakChecked <SubregionStream>
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -80,8 +82,6 @@ public:
|
||||
private:
|
||||
OptionalScopedPointer<InputStream> source;
|
||||
const int64 startPositionInSourceStream, lengthOfSourceStream;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SubregionStream)
|
||||
};
|
||||
|
||||
#endif // BEAST_SUBREGIONSTREAM_BEASTHEADER
|
||||
|
||||
@@ -141,41 +141,6 @@ template <> struct BeastStaticAssert <true> { static void dummy() {} };
|
||||
*/
|
||||
#define static_bassert(expression) beast::BeastStaticAssert<expression>::dummy();
|
||||
|
||||
/** This is a shorthand macro for declaring stubs for a class's copy constructor and operator=.
|
||||
|
||||
For example, instead of
|
||||
@code
|
||||
class MyClass
|
||||
{
|
||||
etc..
|
||||
|
||||
private:
|
||||
MyClass (const MyClass&);
|
||||
MyClass& operator= (const MyClass&);
|
||||
};@endcode
|
||||
|
||||
..you can just write:
|
||||
|
||||
@code
|
||||
class MyClass
|
||||
{
|
||||
etc..
|
||||
|
||||
private:
|
||||
BEAST_DECLARE_NON_COPYABLE (MyClass)
|
||||
};@endcode
|
||||
*/
|
||||
#define BEAST_DECLARE_NON_COPYABLE(className) \
|
||||
className (const className&);\
|
||||
className& operator= (const className&);
|
||||
|
||||
/** This is a shorthand way of writing both a BEAST_DECLARE_NON_COPYABLE and
|
||||
BEAST_LEAK_DETECTOR macro for a class.
|
||||
*/
|
||||
#define BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className) \
|
||||
BEAST_DECLARE_NON_COPYABLE(className) \
|
||||
BEAST_LEAK_DETECTOR(className)
|
||||
|
||||
/** This macro can be added to class definitions to disable the use of new/delete to
|
||||
allocate the object on the heap, forcing it to only be used as a stack or member variable.
|
||||
*/
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
#include <algorithm>
|
||||
#include <cfloat>
|
||||
#include <climits>
|
||||
#include <cmath>
|
||||
#include <cstdarg>
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
@@ -178,14 +179,7 @@ extern BEAST_API bool BEAST_CALLTYPE beast_isRunningUnderDebugger();
|
||||
extern BEAST_API void BEAST_CALLTYPE logAssertion (char const* file, int line) noexcept;
|
||||
|
||||
// These are so common that we include them early
|
||||
|
||||
#include "../memory/beast_Uncopyable.h"
|
||||
#include "../memory/beast_Memory.h"
|
||||
#include "../maths/beast_MathsFunctions.h"
|
||||
#include "../memory/beast_ByteOrder.h"
|
||||
#include "../logging/beast_Logger.h"
|
||||
#include "../memory/beast_LeakedObjectDetector.h"
|
||||
|
||||
// ?
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
/**
|
||||
Contains methods for finding out about the current hardware and OS configuration.
|
||||
*/
|
||||
class BEAST_API SystemStats
|
||||
class BEAST_API SystemStats : Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -194,8 +194,6 @@ private:
|
||||
|
||||
SystemStats();
|
||||
static const CPUFlags& getCPUFlags();
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (SystemStats)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
get a list of all the messages by searching for the TRANS() macro in the Beast source
|
||||
code).
|
||||
*/
|
||||
class BEAST_API LocalisedStrings
|
||||
class BEAST_API LocalisedStrings : LeakChecked <LocalisedStrings>
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -176,8 +176,6 @@ private:
|
||||
StringPairArray translations;
|
||||
|
||||
void loadFromText (const String&, bool ignoreCase);
|
||||
|
||||
BEAST_LEAK_DETECTOR (LocalisedStrings)
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
@see String, StringPairArray
|
||||
*/
|
||||
class BEAST_API StringArray
|
||||
class BEAST_API StringArray : LeakChecked <StringArray>
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -396,10 +396,7 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
Array <String> strings;
|
||||
|
||||
BEAST_LEAK_DETECTOR (StringArray)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
@see StringArray
|
||||
*/
|
||||
class BEAST_API StringPairArray
|
||||
class BEAST_API StringPairArray : LeakChecked <StringPairArray>
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -150,8 +150,6 @@ private:
|
||||
//==============================================================================
|
||||
StringArray keys, values;
|
||||
bool ignoreCase;
|
||||
|
||||
BEAST_LEAK_DETECTOR (StringPairArray)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
This class lets you launch an executable, and read its output. You can also
|
||||
use it to check whether the child process has finished.
|
||||
*/
|
||||
class BEAST_API ChildProcess
|
||||
class BEAST_API ChildProcess : LeakChecked <ChildProcess>, Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -92,8 +92,6 @@ private:
|
||||
class ActiveProcess;
|
||||
friend class ScopedPointer<ActiveProcess>;
|
||||
ScopedPointer<ActiveProcess> activeProcess;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChildProcess)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
@see ScopedLock, ScopedTryLock, ScopedUnlock, SpinLock, ReadWriteLock, Thread, InterProcessLock
|
||||
*/
|
||||
class BEAST_API CriticalSection
|
||||
class BEAST_API CriticalSection : Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -111,8 +111,6 @@ private:
|
||||
#else
|
||||
mutable pthread_mutex_t internal;
|
||||
#endif
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (CriticalSection)
|
||||
};
|
||||
|
||||
|
||||
@@ -126,7 +124,7 @@ private:
|
||||
|
||||
@see CriticalSection, Array, OwnedArray, ReferenceCountedArray
|
||||
*/
|
||||
class BEAST_API DummyCriticalSection
|
||||
class BEAST_API DummyCriticalSection : Uncopyable
|
||||
{
|
||||
public:
|
||||
inline DummyCriticalSection() noexcept {}
|
||||
@@ -145,9 +143,6 @@ public:
|
||||
|
||||
/** A dummy scoped-unlocker type to use with a dummy critical section. */
|
||||
typedef ScopedLockType ScopedUnlockType;
|
||||
|
||||
private:
|
||||
BEAST_DECLARE_NON_COPYABLE (DummyCriticalSection)
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
Since the DLL is freed when this object is deleted, it's handy for managing
|
||||
library lifetimes using RAII.
|
||||
*/
|
||||
class BEAST_API DynamicLibrary
|
||||
class BEAST_API DynamicLibrary : LeakChecked <DynamicLibrary>, Uncopyable
|
||||
{
|
||||
public:
|
||||
/** Creates an unopened DynamicLibrary object.
|
||||
@@ -72,8 +72,6 @@ public:
|
||||
|
||||
private:
|
||||
void* handle;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DynamicLibrary)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
@see Timer
|
||||
*/
|
||||
class BEAST_API HighResolutionTimer
|
||||
class BEAST_API HighResolutionTimer : LeakChecked <HighResolutionTimer>, Uncopyable
|
||||
{
|
||||
protected:
|
||||
/** Creates a HighResolutionTimer.
|
||||
@@ -96,8 +96,6 @@ private:
|
||||
friend struct Pimpl;
|
||||
friend class ScopedPointer<Pimpl>;
|
||||
ScopedPointer<Pimpl> pimpl;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HighResolutionTimer)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
@see CriticalSection
|
||||
*/
|
||||
class BEAST_API InterProcessLock
|
||||
class BEAST_API InterProcessLock : Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
|
||||
@see ScopedLock
|
||||
*/
|
||||
class ScopedLockType
|
||||
class ScopedLockType : Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -106,8 +106,6 @@ public:
|
||||
//==============================================================================
|
||||
InterProcessLock& ipLock;
|
||||
bool lockWasSuccessful;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (ScopedLockType)
|
||||
};
|
||||
|
||||
private:
|
||||
@@ -118,8 +116,6 @@ private:
|
||||
|
||||
CriticalSection lock;
|
||||
String name;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (InterProcessLock)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
@see Thread, BEASTApplication
|
||||
*/
|
||||
class BEAST_API Process
|
||||
class BEAST_API Process : Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -138,7 +138,6 @@ public:
|
||||
|
||||
private:
|
||||
Process();
|
||||
BEAST_DECLARE_NON_COPYABLE (Process)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
@see ScopedReadLock, ScopedWriteLock, CriticalSection
|
||||
*/
|
||||
class BEAST_API ReadWriteLock
|
||||
class BEAST_API ReadWriteLock : Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -146,8 +146,6 @@ private:
|
||||
};
|
||||
|
||||
mutable Array <ThreadRecursionCount> readerThreads;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (ReadWriteLock)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
@see GenericScopedUnlock, CriticalSection, SpinLock, ScopedLock, ScopedUnlock
|
||||
*/
|
||||
template <class LockType>
|
||||
class GenericScopedLock
|
||||
class GenericScopedLock : Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -76,8 +76,6 @@ public:
|
||||
private:
|
||||
//==============================================================================
|
||||
const LockType& lock_;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (GenericScopedLock)
|
||||
};
|
||||
|
||||
|
||||
@@ -120,7 +118,7 @@ private:
|
||||
@see GenericScopedLock, CriticalSection, ScopedLock, ScopedUnlock
|
||||
*/
|
||||
template <class LockType>
|
||||
class GenericScopedUnlock
|
||||
class GenericScopedUnlock : Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -149,8 +147,6 @@ public:
|
||||
private:
|
||||
//==============================================================================
|
||||
const LockType& lock_;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (GenericScopedUnlock)
|
||||
};
|
||||
|
||||
|
||||
@@ -190,7 +186,7 @@ private:
|
||||
@see CriticalSection::tryEnter, GenericScopedLock, GenericScopedUnlock
|
||||
*/
|
||||
template <class LockType>
|
||||
class GenericScopedTryLock
|
||||
class GenericScopedTryLock : Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -224,8 +220,6 @@ private:
|
||||
//==============================================================================
|
||||
const LockType& lock_;
|
||||
const bool lockWasSuccessful;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (GenericScopedTryLock)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
@see ReadWriteLock, ScopedWriteLock
|
||||
*/
|
||||
class BEAST_API ScopedReadLock
|
||||
class BEAST_API ScopedReadLock : Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -79,8 +79,6 @@ public:
|
||||
private:
|
||||
//==============================================================================
|
||||
const ReadWriteLock& lock_;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (ScopedReadLock)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
@see ReadWriteLock, ScopedReadLock
|
||||
*/
|
||||
class BEAST_API ScopedWriteLock
|
||||
class BEAST_API ScopedWriteLock : Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -79,8 +79,6 @@ public:
|
||||
private:
|
||||
//==============================================================================
|
||||
const ReadWriteLock& lock_;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (ScopedWriteLock)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
SpinDelay::SpinDelay ()
|
||||
: m_count (0)
|
||||
{
|
||||
}
|
||||
|
||||
void SpinDelay::pause ()
|
||||
{
|
||||
if (++m_count > 20)
|
||||
Thread::yield ();
|
||||
}
|
||||
@@ -20,22 +20,14 @@
|
||||
#ifndef BEAST_SPINDELAY_BEASTHEADER
|
||||
#define BEAST_SPINDELAY_BEASTHEADER
|
||||
|
||||
//
|
||||
// Synchronization element
|
||||
//
|
||||
|
||||
/** A simple delay used to synchronize threads.
|
||||
*/
|
||||
class BEAST_API SpinDelay
|
||||
{
|
||||
public:
|
||||
SpinDelay () : m_count (0)
|
||||
{
|
||||
}
|
||||
SpinDelay ();
|
||||
|
||||
inline void pause ()
|
||||
{
|
||||
if (++m_count > 20)
|
||||
Thread::yield ();
|
||||
}
|
||||
void pause ();
|
||||
|
||||
private:
|
||||
int m_count;
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
@see CriticalSection
|
||||
*/
|
||||
class BEAST_API SpinLock
|
||||
class BEAST_API SpinLock : Uncopyable
|
||||
{
|
||||
public:
|
||||
inline SpinLock() noexcept {}
|
||||
@@ -80,8 +80,6 @@ public:
|
||||
private:
|
||||
//==============================================================================
|
||||
mutable Atomic<int> lock;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (SpinLock)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -48,14 +48,12 @@ Thread::~Thread()
|
||||
//==============================================================================
|
||||
// Use a ref-counted object to hold this shared data, so that it can outlive its static
|
||||
// shared pointer when threads are still running during static shutdown.
|
||||
struct CurrentThreadHolder : public ReferenceCountedObject
|
||||
struct CurrentThreadHolder : public ReferenceCountedObject
|
||||
{
|
||||
CurrentThreadHolder() noexcept {}
|
||||
|
||||
typedef ReferenceCountedObjectPtr <CurrentThreadHolder> Ptr;
|
||||
ThreadLocalValue<Thread*> value;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (CurrentThreadHolder)
|
||||
};
|
||||
|
||||
static char currentThreadHolderLock [sizeof (SpinLock)]; // (statically initialised to zeros).
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
@see CriticalSection, WaitableEvent, Process, ThreadWithProgressWindow,
|
||||
MessageManagerLock
|
||||
*/
|
||||
class BEAST_API Thread
|
||||
class BEAST_API Thread : LeakChecked <Thread>, Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -280,8 +280,6 @@ private:
|
||||
void killThread();
|
||||
void threadEntryPoint();
|
||||
static bool setThreadPriority (void*, int);
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Thread)
|
||||
};
|
||||
|
||||
#endif // BEAST_THREAD_BEASTHEADER
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
is deleted.
|
||||
*/
|
||||
template <typename Type>
|
||||
class ThreadLocalValue
|
||||
class ThreadLocalValue : Uncopyable
|
||||
{
|
||||
public:
|
||||
/** */
|
||||
@@ -170,7 +170,7 @@ public:
|
||||
private:
|
||||
//==============================================================================
|
||||
#if BEAST_NO_COMPILER_THREAD_LOCAL
|
||||
struct ObjectHolder
|
||||
struct ObjectHolder : Uncopyable
|
||||
{
|
||||
ObjectHolder (const Thread::ThreadID& tid)
|
||||
: threadId (tid), object()
|
||||
@@ -179,15 +179,11 @@ private:
|
||||
Thread::ThreadID threadId;
|
||||
ObjectHolder* next;
|
||||
Type object;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (ObjectHolder)
|
||||
};
|
||||
|
||||
mutable Atomic<ObjectHolder*> first;
|
||||
SpinLock lock;
|
||||
#endif
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (ThreadLocalValue)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -53,7 +53,9 @@ void ThreadPoolJob::signalJobShouldExit()
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
class ThreadPool::ThreadPoolThread : public Thread
|
||||
class ThreadPool::ThreadPoolThread
|
||||
: public Thread
|
||||
, LeakChecked <ThreadPoolThread>
|
||||
{
|
||||
public:
|
||||
ThreadPoolThread (ThreadPool& pool_)
|
||||
@@ -73,8 +75,6 @@ public:
|
||||
|
||||
private:
|
||||
ThreadPool& pool;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ThreadPoolThread)
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
||||
@@ -46,7 +46,7 @@ class ThreadPoolThread;
|
||||
|
||||
@see ThreadPool, Thread
|
||||
*/
|
||||
class BEAST_API ThreadPoolJob
|
||||
class BEAST_API ThreadPoolJob : LeakChecked <ThreadPoolJob>, Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -125,8 +125,6 @@ private:
|
||||
String jobName;
|
||||
ThreadPool* pool;
|
||||
bool shouldStop, isActive, shouldBeDeleted;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ThreadPoolJob)
|
||||
};
|
||||
|
||||
|
||||
@@ -139,7 +137,7 @@ private:
|
||||
|
||||
@see ThreadPoolJob, Thread
|
||||
*/
|
||||
class BEAST_API ThreadPool
|
||||
class BEAST_API ThreadPool : LeakChecked <ThreadPool>, Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -305,8 +303,6 @@ private:
|
||||
// Note that this method has changed, and no longer has a parameter to indicate
|
||||
// whether the jobs should be deleted - see the new method for details.
|
||||
void removeAllJobs (bool, int, bool);
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ThreadPool)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -79,7 +79,9 @@ private:
|
||||
|
||||
@see TimeSliceClient, Thread
|
||||
*/
|
||||
class BEAST_API TimeSliceThread : public Thread
|
||||
class BEAST_API TimeSliceThread
|
||||
: public Thread
|
||||
, LeakChecked <TimeSliceThread>
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -139,8 +141,6 @@ private:
|
||||
TimeSliceClient* clientBeingCalled;
|
||||
|
||||
TimeSliceClient* getNextClient (int index) const;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TimeSliceThread)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
calling thread until another thread wakes it up by calling the signal()
|
||||
method.
|
||||
*/
|
||||
class BEAST_API WaitableEvent
|
||||
class BEAST_API WaitableEvent : LeakChecked <WaitableEvent>, Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -106,8 +106,6 @@ private:
|
||||
mutable pthread_mutex_t mutex;
|
||||
mutable bool triggered, manualReset;
|
||||
#endif
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WaitableEvent)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class UnitTestRunner;
|
||||
|
||||
@see UnitTestRunner
|
||||
*/
|
||||
class BEAST_API UnitTest
|
||||
class BEAST_API UnitTest : Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -164,8 +164,6 @@ private:
|
||||
//==============================================================================
|
||||
const String name;
|
||||
UnitTestRunner* runner;
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (UnitTest)
|
||||
};
|
||||
|
||||
|
||||
@@ -181,7 +179,7 @@ private:
|
||||
|
||||
@see UnitTest
|
||||
*/
|
||||
class BEAST_API UnitTestRunner
|
||||
class BEAST_API UnitTestRunner : Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -277,8 +275,6 @@ private:
|
||||
|
||||
void addPass();
|
||||
void addFail (const String& failureMessage);
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE (UnitTestRunner)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class InputSource;
|
||||
|
||||
@see XmlElement
|
||||
*/
|
||||
class BEAST_API XmlDocument
|
||||
class BEAST_API XmlDocument : LeakChecked <XmlDocument>, Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -173,8 +173,6 @@ private:
|
||||
String expandEntity (const String& entity);
|
||||
String expandExternalEntity (const String& entity);
|
||||
String getParameterEntity (const String& entity);
|
||||
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (XmlDocument)
|
||||
};
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user