mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-29 23:45:51 +00:00
Tidy up LeakChecked and configuration macro
This commit is contained in:
@@ -67,7 +67,7 @@
|
||||
specific classes.
|
||||
*/
|
||||
#ifndef BEAST_CHECK_MEMORY_LEAKS
|
||||
#define BEAST_CHECK_MEMORY_LEAKS 1
|
||||
//#define BEAST_CHECK_MEMORY_LEAKS 0
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -120,8 +120,4 @@
|
||||
//#define BEAST_BIND_USES_TR1 1
|
||||
//#define BEAST_BIND_USES_BOOST 1
|
||||
|
||||
#ifndef BEAST_USE_LEAKCHECKED
|
||||
#define BEAST_USE_LEAKCHECKED 1
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -120,8 +120,4 @@
|
||||
//#define BEAST_BIND_USES_TR1 1
|
||||
//#define BEAST_BIND_USES_BOOST 1
|
||||
|
||||
#ifndef BEAST_USE_LEAKCHECKED
|
||||
#define BEAST_USE_LEAKCHECKED 1
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -208,6 +208,7 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\threads\beast_TimeSliceThread.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\threads\beast_WaitableEvent.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\time\beast_PerformanceCounter.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\time\beast_PerformedAtExit.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\time\beast_RelativeTime.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\time\beast_Time.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\unit_tests\beast_UnitTest.h" />
|
||||
@@ -778,6 +779,12 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\time\beast_PerformedAtExit.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\time\beast_RelativeTime.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
|
||||
@@ -608,6 +608,9 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\beast_Interval.h">
|
||||
<Filter>beast_core\maths</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\time\beast_PerformedAtExit.h">
|
||||
<Filter>beast_core\time</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\modules\beast_core\beast_core.cpp">
|
||||
@@ -946,6 +949,9 @@
|
||||
<ClCompile Include="..\..\modules\beast_core\native\beast_win32_FPUFlags.cpp">
|
||||
<Filter>beast_core\native</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\time\beast_PerformedAtExit.cpp">
|
||||
<Filter>beast_core\time</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="..\..\TODO.txt" />
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
BEAST TODO
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
- Make OwnedArray add routines return a pointer instead of reference
|
||||
|
||||
- Tidy up CacheLine, MemoryAlignment
|
||||
|
||||
- Remove anything having to do with DLL builds like
|
||||
|
||||
@@ -81,10 +81,6 @@
|
||||
#define BEAST_BOOST_IS_AVAILABLE 0
|
||||
#endif
|
||||
|
||||
#ifndef BEAST_USE_LEAKCHECKED
|
||||
#define BEAST_USE_LEAKCHECKED BEAST_CHECK_MEMORY_LEAKS
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// This is a hack to fix boost's goofy placeholders
|
||||
@@ -208,6 +204,7 @@ namespace beast
|
||||
#include "containers/beast_LockFreeStack.h"
|
||||
#include "threads/beast_SpinDelay.h"
|
||||
#include "memory/beast_StaticObject.h"
|
||||
#include "time/beast_PerformedAtExit.h"
|
||||
#include "diagnostic/beast_LeakChecked.h"
|
||||
#include "memory/beast_Memory.h"
|
||||
#include "memory/beast_ByteOrder.h"
|
||||
@@ -261,7 +258,6 @@ namespace beast
|
||||
#include "memory/beast_ReferenceCountedObject.h"
|
||||
#include "memory/beast_ScopedPointer.h"
|
||||
#include "threads/beast_SpinLock.h"
|
||||
#include "time/beast_PerformedAtExit.h"
|
||||
#include "memory/beast_SharedSingleton.h"
|
||||
#include "memory/beast_WeakReference.h"
|
||||
#include "memory/beast_MemoryAlignment.h"
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#if BEAST_USE_LEAKCHECKED
|
||||
namespace Implemented
|
||||
{
|
||||
|
||||
class LeakCheckedBase::CounterBase::Singleton
|
||||
{
|
||||
@@ -27,16 +28,16 @@ public:
|
||||
m_list.push_front (counter);
|
||||
}
|
||||
|
||||
void detectAllLeaks ()
|
||||
void checkForLeaks ()
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
CounterBase* counter = m_list.pop_front ();
|
||||
CounterBase* const counter = m_list.pop_front ();
|
||||
|
||||
if (!counter)
|
||||
break;
|
||||
|
||||
counter->detectLeaks ();
|
||||
counter->checkForLeaks ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +49,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
friend class LeakCheckedBase;
|
||||
|
||||
LockFreeStack <CounterBase> m_list;
|
||||
};
|
||||
|
||||
@@ -58,12 +61,7 @@ LeakCheckedBase::CounterBase::CounterBase ()
|
||||
Singleton::getInstance ().push_back (this);
|
||||
}
|
||||
|
||||
void LeakCheckedBase::CounterBase::detectAllLeaks ()
|
||||
{
|
||||
Singleton::getInstance ().detectAllLeaks ();
|
||||
}
|
||||
|
||||
void LeakCheckedBase::CounterBase::detectLeaks ()
|
||||
void LeakCheckedBase::CounterBase::checkForLeaks ()
|
||||
{
|
||||
// If there's a runtime error from this line, it means there's
|
||||
// an order of destruction problem between different translation units!
|
||||
@@ -91,9 +89,9 @@ void LeakCheckedBase::CounterBase::detectLeaks ()
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void LeakCheckedBase::detectAllLeaks ()
|
||||
void LeakCheckedBase::checkForLeaks ()
|
||||
{
|
||||
CounterBase::detectAllLeaks ();
|
||||
CounterBase::Singleton::getInstance ().checkForLeaks ();
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -17,20 +17,14 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_LEAKCHECKED_BEASTHEADER
|
||||
#define BEAST_LEAKCHECKED_BEASTHEADER
|
||||
#ifndef BEAST_LEAKCHECKED_H_INCLUDED
|
||||
#define BEAST_LEAKCHECKED_H_INCLUDED
|
||||
|
||||
//
|
||||
// Derived classes are automatically leak-checked on exit
|
||||
//
|
||||
|
||||
#if BEAST_USE_LEAKCHECKED
|
||||
namespace Implemented
|
||||
{
|
||||
|
||||
class BEAST_API LeakCheckedBase
|
||||
{
|
||||
public:
|
||||
static void detectAllLeaks ();
|
||||
|
||||
protected:
|
||||
class CounterBase : public LockFreeStack <CounterBase>::Node
|
||||
{
|
||||
@@ -51,18 +45,23 @@ protected:
|
||||
|
||||
virtual char const* getClassName () const = 0;
|
||||
|
||||
static void detectAllLeaks ();
|
||||
|
||||
private:
|
||||
void detectLeaks ();
|
||||
void checkForLeaks ();
|
||||
|
||||
virtual void checkPureVirtual () const = 0;
|
||||
|
||||
protected:
|
||||
private:
|
||||
friend class LeakCheckedBase;
|
||||
|
||||
class Singleton;
|
||||
|
||||
Atomic <int> m_count;
|
||||
};
|
||||
|
||||
private:
|
||||
friend class PerformedAtExit::ExitHook;
|
||||
|
||||
static void checkForLeaks ();
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -81,7 +80,7 @@ protected:
|
||||
getCounter ().increment ();
|
||||
}
|
||||
|
||||
LeakChecked (const LeakChecked&) noexcept
|
||||
LeakChecked (LeakChecked const&) noexcept
|
||||
{
|
||||
getCounter ().increment ();
|
||||
}
|
||||
@@ -113,6 +112,8 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
// Singleton that maintains the count of this object
|
||||
//
|
||||
class Counter : public CounterBase
|
||||
{
|
||||
public:
|
||||
@@ -139,6 +140,8 @@ private:
|
||||
return typeid (Object).name ();
|
||||
}
|
||||
|
||||
// Retrieve the singleton for this object
|
||||
//
|
||||
static Counter& getCounter () noexcept
|
||||
{
|
||||
static Counter* volatile s_instance;
|
||||
@@ -156,14 +159,20 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
#else
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Dummy
|
||||
{
|
||||
|
||||
class BEAST_API LeakCheckedBase
|
||||
{
|
||||
private:
|
||||
friend class PerformedAtExit;
|
||||
|
||||
static void detectAllLeaks () { }
|
||||
public:
|
||||
static void checkForLeaks () { }
|
||||
};
|
||||
|
||||
template <class Object>
|
||||
@@ -171,6 +180,18 @@ struct LeakChecked : LeakCheckedBase
|
||||
{
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Lift the corresponding implementation
|
||||
//
|
||||
#if BEAST_CHECK_MEMORY_LEAKS
|
||||
using Implemented::LeakChecked;
|
||||
using Implemented::LeakCheckedBase;
|
||||
#else
|
||||
using Dummy::LeakChecked;
|
||||
using Dummy::LeakCheckedBase;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// Allows turning off of all padding,
|
||||
// e.g. for memory-constrained systems or testing.
|
||||
//
|
||||
#define GLOBAL_PADDING_ENABLED 0
|
||||
#define GLOBAL_PADDING_ENABLED 1
|
||||
|
||||
namespace CacheLine
|
||||
{
|
||||
@@ -32,77 +32,76 @@ namespace CacheLine
|
||||
|
||||
// Pads an object so that it starts on a cache line boundary.
|
||||
//
|
||||
/** Pad an object to start on a cache line boundary.
|
||||
|
||||
Up to 8 constructor parameters are passed through.
|
||||
*/
|
||||
template <typename T>
|
||||
class Aligned
|
||||
{
|
||||
public:
|
||||
~Aligned ()
|
||||
{
|
||||
ptr ()->~T ();
|
||||
}
|
||||
|
||||
Aligned ()
|
||||
{
|
||||
new (ptr ()) T;
|
||||
}
|
||||
|
||||
template <class T1>
|
||||
explicit Aligned (const T1& t1)
|
||||
Aligned (T1 t1)
|
||||
{
|
||||
new (ptr ()) T (t1);
|
||||
}
|
||||
|
||||
template <class T1, class T2>
|
||||
Aligned (const T1& t1, const T2& t2)
|
||||
Aligned (T1 t1, T2 t2)
|
||||
{
|
||||
new (ptr ()) T (t1, t2);
|
||||
}
|
||||
|
||||
template <class T1, class T2, class T3>
|
||||
Aligned (const T1& t1, const T2& t2, const T3& t3)
|
||||
Aligned (T1 t1, T2 t2, T3 t3)
|
||||
{
|
||||
new (ptr ()) T (t1, t2, t3);
|
||||
}
|
||||
|
||||
template <class T1, class T2, class T3, class T4>
|
||||
Aligned (const T1& t1, const T2& t2, const T3& t3, const T4& t4)
|
||||
Aligned (T1 t1, T2 t2, T3 t3, T4 t4)
|
||||
{
|
||||
new (ptr ()) T (t1, t2, t3, t4);
|
||||
}
|
||||
|
||||
template <class T1, class T2, class T3, class T4, class T5>
|
||||
Aligned (const T1& t1, const T2& t2, const T3& t3,
|
||||
const T4& t4, const T5& t5)
|
||||
Aligned (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
|
||||
{
|
||||
new (ptr ()) T (t1, t2, t3, t4, t5);
|
||||
}
|
||||
|
||||
template <class T1, class T2, class T3, class T4, class T5, class T6>
|
||||
Aligned (const T1& t1, const T2& t2, const T3& t3,
|
||||
const T4& t4, const T5& t5, const T6& t6)
|
||||
Aligned (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
|
||||
{
|
||||
new (ptr ()) T (t1, t2, t3, t4, t5, t6);
|
||||
}
|
||||
|
||||
template < class T1, class T2, class T3, class T4,
|
||||
class T5, class T6, class T7 >
|
||||
Aligned (const T1& t1, const T2& t2, const T3& t3, const T4& t4,
|
||||
const T5& t5, const T6& t6, const T7& t7)
|
||||
template <class T1, class T2, class T3, class T4, class T5, class T6, class T7>
|
||||
Aligned (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
|
||||
{
|
||||
new (ptr ()) T (t1, t2, t3, t4, t5, t6, t7);
|
||||
}
|
||||
|
||||
template < class T1, class T2, class T3, class T4,
|
||||
class T5, class T6, class T7, class T8 >
|
||||
Aligned (const T1& t1, const T2& t2, const T3& t3, const T4& t4,
|
||||
const T5& t5, const T6& t6, const T7& t7, const T8& t8)
|
||||
template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8>
|
||||
Aligned (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
|
||||
{
|
||||
new (ptr ()) T (t1, t2, t3, t4, t5, t6, t7, t8);
|
||||
}
|
||||
|
||||
void operator= (T const& other)
|
||||
~Aligned ()
|
||||
{
|
||||
ptr ()->~T ();
|
||||
}
|
||||
|
||||
T& operator= (T const& other)
|
||||
{
|
||||
*ptr () = other;
|
||||
return *ptr ();
|
||||
}
|
||||
|
||||
inline T& operator* () noexcept { return *ptr (); }
|
||||
@@ -110,22 +109,10 @@ public:
|
||||
inline operator T& () noexcept { return *ptr (); }
|
||||
inline operator T* () noexcept { return ptr (); }
|
||||
|
||||
inline const T& operator* () const noexcept
|
||||
{
|
||||
return *ptr ();
|
||||
}
|
||||
inline const T* operator-> () const noexcept
|
||||
{
|
||||
return ptr ();
|
||||
}
|
||||
inline operator const T& () const noexcept
|
||||
{
|
||||
return *ptr ();
|
||||
}
|
||||
inline operator const T* () const noexcept
|
||||
{
|
||||
return ptr ();
|
||||
}
|
||||
inline const T& operator* () const noexcept { return *ptr (); }
|
||||
inline const T* operator-> () const noexcept { return ptr (); }
|
||||
inline operator T const& () const noexcept { return *ptr (); }
|
||||
inline operator T const* () const noexcept { return ptr (); }
|
||||
|
||||
private:
|
||||
inline T* ptr () noexcept
|
||||
@@ -138,62 +125,74 @@ private:
|
||||
*/
|
||||
}
|
||||
|
||||
char m_storage [ (sizeof (T) + Memory::cacheLineAlignMask)
|
||||
& ~Memory::cacheLineAlignMask];
|
||||
char m_storage [ (sizeof (T) + Memory::cacheLineAlignMask) & ~Memory::cacheLineAlignMask];
|
||||
};
|
||||
|
||||
// Holds an object padded it to completely fill a CPU cache line.
|
||||
// The caller must ensure that this object starts at the beginning
|
||||
// of a cache line.
|
||||
//
|
||||
/** End-pads an object to completely fill straddling CPU cache lines.
|
||||
|
||||
The caller must ensure that this object starts at the beginning
|
||||
of a cache line.
|
||||
*/
|
||||
template <typename T>
|
||||
class Padded
|
||||
{
|
||||
public:
|
||||
Padded ()
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
template <class T1>
|
||||
explicit Padded (const T1& t1)
|
||||
: m_t (t1) { }
|
||||
explicit Padded (T1 t1)
|
||||
: m_t (t1)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T1, class T2>
|
||||
Padded (const T1& t1, const T2& t2)
|
||||
: m_t (t1, t2) { }
|
||||
Padded (T1 t1, T2 t2)
|
||||
: m_t (t1, t2)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T1, class T2, class T3>
|
||||
Padded (const T1& t1, const T2& t2, const T3& t3)
|
||||
: m_t (t1, t2, t3) { }
|
||||
Padded (T1 t1, T2 t2, T3 t3)
|
||||
: m_t (t1, t2, t3)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T1, class T2, class T3, class T4>
|
||||
Padded (const T1& t1, const T2& t2, const T3& t3, const T4& t4)
|
||||
: m_t (t1, t2, t3, t4) { }
|
||||
Padded (T1 t1, T2 t2, T3 t3, T4 t4)
|
||||
: m_t (t1, t2, t3, t4)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T1, class T2, class T3, class T4, class T5>
|
||||
Padded (const T1& t1, const T2& t2, const T3& t3,
|
||||
const T4& t4, const T5& t5)
|
||||
: m_t (t1, t2, t3, t4, t5) { }
|
||||
Padded (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
|
||||
: m_t (t1, t2, t3, t4, t5)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T1, class T2, class T3, class T4, class T5, class T6>
|
||||
Padded (const T1& t1, const T2& t2, const T3& t3,
|
||||
const T4& t4, const T5& t5, const T6& t6)
|
||||
: m_t (t1, t2, t3, t4, t5, t6) { }
|
||||
Padded (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
|
||||
: m_t (t1, t2, t3, t4, t5, t6)
|
||||
{
|
||||
}
|
||||
|
||||
template < class T1, class T2, class T3, class T4,
|
||||
class T5, class T6, class T7 >
|
||||
Padded (const T1& t1, const T2& t2, const T3& t3, const T4& t4,
|
||||
const T5& t5, const T6& t6, const T7& t7)
|
||||
: m_t (t1, t2, t3, t4, t5, t6, t7) { }
|
||||
template <class T1, class T2, class T3, class T4, class T5, class T6, class T7>
|
||||
Padded (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
|
||||
: m_t (t1, t2, t3, t4, t5, t6, t7)
|
||||
{
|
||||
}
|
||||
|
||||
template < class T1, class T2, class T3, class T4,
|
||||
class T5, class T6, class T7, class T8 >
|
||||
Padded (const T1& t1, const T2& t2, const T3& t3, const T4& t4,
|
||||
const T5& t5, const T6& t6, const T7& t7, const T8& t8)
|
||||
: m_t (t1, t2, t3, t4, t5, t6, t7, t8) { }
|
||||
template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8>
|
||||
Padded (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
|
||||
: m_t (t1, t2, t3, t4, t5, t6, t7, t8)
|
||||
{
|
||||
}
|
||||
|
||||
void operator= (const T& other)
|
||||
T& operator= (T const& other)
|
||||
{
|
||||
m_t = other;
|
||||
return m_t;
|
||||
}
|
||||
|
||||
T& operator* () noexcept { return m_t; }
|
||||
@@ -201,22 +200,10 @@ public:
|
||||
operator T& () noexcept { return m_t; }
|
||||
operator T* () noexcept { return &m_t; }
|
||||
|
||||
const T& operator* () const noexcept
|
||||
{
|
||||
return m_t;
|
||||
}
|
||||
const T* operator-> () const noexcept
|
||||
{
|
||||
return &m_t;
|
||||
}
|
||||
operator const T& () const noexcept
|
||||
{
|
||||
return m_t;
|
||||
}
|
||||
operator const T* () const noexcept
|
||||
{
|
||||
return &m_t;
|
||||
}
|
||||
const T& operator* () const noexcept { return m_t; }
|
||||
const T* operator-> () const noexcept { return &m_t; }
|
||||
operator T const& () const noexcept { return m_t; }
|
||||
operator T const* () const noexcept { return &m_t; }
|
||||
|
||||
private:
|
||||
T m_t;
|
||||
|
||||
@@ -25,6 +25,8 @@ public:
|
||||
private:
|
||||
~ExitHook ()
|
||||
{
|
||||
// Call all PerformedAtExit objects
|
||||
//
|
||||
PerformedAtExit* object = s_list->pop_front ();
|
||||
|
||||
while (object != nullptr)
|
||||
@@ -34,7 +36,9 @@ private:
|
||||
object = s_list->pop_front ();
|
||||
}
|
||||
|
||||
LeakCheckedBase::detectAllLeaks ();
|
||||
// Now do the leak checking
|
||||
//
|
||||
LeakCheckedBase::checkForLeaks ();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -36,6 +36,9 @@
|
||||
//
|
||||
class BEAST_API PerformedAtExit : public LockFreeStack <PerformedAtExit>::Node
|
||||
{
|
||||
public:
|
||||
class ExitHook;
|
||||
|
||||
protected:
|
||||
PerformedAtExit ();
|
||||
virtual ~PerformedAtExit () { }
|
||||
@@ -44,9 +47,6 @@ protected:
|
||||
/** Called at program exit.
|
||||
*/
|
||||
virtual void performAtExit () = 0;
|
||||
|
||||
private:
|
||||
class ExitHook;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
29
TODO.txt
29
TODO.txt
@@ -2,28 +2,40 @@
|
||||
RIPPLE TODO
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
- Create SharedData <LoadState>, move all load related state variables currently
|
||||
protected by separated mutexes in different classes into the LoadState, and
|
||||
use read/write locking semantics to update the values. Later, use Listeners
|
||||
to notify dependent code to resolve the dependency inversion.
|
||||
|
||||
- Merge ripple_Version.h and ripple_BuildVersion.h
|
||||
|
||||
- Rename LoadMonitor to LoadMeter, change LoadEvent to LoadMeter::ScopedSample
|
||||
|
||||
- Rename LedgerMaster to Ledgers, create ILedgers interface.
|
||||
|
||||
- Restructure the ripple sources to have this directory structure:
|
||||
/Source/ripple/ripple_core/ripple_core.h
|
||||
etc...
|
||||
/...
|
||||
/Source/Subtrees/... ?
|
||||
PROBLEM: Where to put BeastConfig.h ?
|
||||
|
||||
- Turn on MSVC debug CRT heap checking with file and line reporting <crtdbg>
|
||||
- Figure out where previous ledgers go after a call to LedgerMaster::pushLedger()
|
||||
and see if it is possible to clean up the leaks on exit.
|
||||
|
||||
- Replace all NULL with nullptr
|
||||
|
||||
- Rewrite TxFormats to use beast containers and RAII, and not leak
|
||||
- Add ICore interface
|
||||
- Make TxFormats a member of ICore instead of a singleton.
|
||||
|
||||
- Rename LoadMonitor to LoadMeter, change LoadEvent to LoadMeter::ScopedSample
|
||||
- Make TxFormats a member of ICore instead of a singleton.
|
||||
PROBLEM: STObject derived classes like STInt16 make direct use of the
|
||||
singleton. It might have to remain a singleton. At the very least,
|
||||
it should be a SharedSingleton to resolve ordering issues.
|
||||
|
||||
- Rename include guards to boost style, e.g. RIPPLE_LOG_H_INCLUDED
|
||||
|
||||
- Replace C11X with BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS
|
||||
|
||||
- Fix all leaks on exit (!)
|
||||
|
||||
Say there's a leak, a ledger that can never be accessed is locked in some
|
||||
structure. If the organized teardown code frees that structure, the leak
|
||||
will not be reported.
|
||||
@@ -43,7 +55,8 @@ RIPPLE TODO
|
||||
|
||||
- Remove "ENABLE_INSECURE" when the time is right.
|
||||
|
||||
- lift unique_ptr / auto_ptr into ripple namespace, or replace with ScopedPointer
|
||||
- lift unique_ptr / auto_ptr into ripple namespace,
|
||||
or replace with ScopedPointer (preferred)
|
||||
|
||||
- Make LevelDB and Ripple code work with both Unicode and non-Unicode Windows APIs
|
||||
|
||||
@@ -125,6 +138,8 @@ Interfaces
|
||||
would be more clear:
|
||||
bool write (OutputStream& stream);
|
||||
|
||||
We have beast for InputStream and OutputStream, we can use those now.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
boost
|
||||
|
||||
@@ -82,6 +82,12 @@ public:
|
||||
|
||||
bool isLoaded ()
|
||||
{
|
||||
// VFALCO TODO This could be replaced with a SharedData and
|
||||
// using a read/write lock instead of a critical section.
|
||||
//
|
||||
// NOTE This applies to all the locking in this class.
|
||||
//
|
||||
//
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
return (raiseCount != 0) || (mLocalTxnLoadFee != lftNormalFee);
|
||||
}
|
||||
|
||||
@@ -124,22 +124,24 @@ int rippleMain (int argc, char** argv)
|
||||
|
||||
// Checks the heap at every allocation and deallocation (slow).
|
||||
//
|
||||
Debug::setAlwaysCheckHeap (false);
|
||||
//Debug::setAlwaysCheckHeap (false);
|
||||
|
||||
// Keeps freed memory blocks and fills them with a guard value.
|
||||
//
|
||||
Debug::setHeapDelayedFree (false);
|
||||
//Debug::setHeapDelayedFree (false);
|
||||
|
||||
// At exit, reports all memory blocks which have not been freed.
|
||||
//
|
||||
#if 1
|
||||
Debug::setHeapReportLeaks (false);
|
||||
//Debug::setHeapReportLeaks (false);
|
||||
|
||||
#else
|
||||
// This is some temporary leak checking test code
|
||||
//
|
||||
Debug::setHeapReportLeaks (true);
|
||||
|
||||
malloc (512); // Any leaks before this line in the output are from static initializations.
|
||||
|
||||
ThreadWithCallQueue t ("test");
|
||||
GlobalPagedFreeStore::getInstance ();
|
||||
t.start ();
|
||||
|
||||
@@ -2254,6 +2254,7 @@ void PeerImp::doProofOfWork (Job&, boost::weak_ptr <Peer> peer, ProofOfWork::poi
|
||||
|
||||
void PeerImp::doFetchPack (const boost::shared_ptr<protocol::TMGetObjectByHash>& packet)
|
||||
{
|
||||
// VFALCO TODO Invert this dependency using an observer and shared state object.
|
||||
if (getApp().getFeeTrack ().isLoaded ())
|
||||
{
|
||||
WriteLog (lsINFO, Peer) << "Too busy to make fetch pack";
|
||||
@@ -2386,12 +2387,13 @@ Peer::pointer Peer::New (boost::asio::io_service& io_service,
|
||||
return Peer::pointer (new PeerImp (io_service, ctx, id, inbound));
|
||||
}
|
||||
|
||||
void Peer::applyLoadCharge (const boost::weak_ptr<Peer>& wp, LoadType l)
|
||||
void Peer::applyLoadCharge (boost::weak_ptr <Peer>& peerToPunish,
|
||||
LoadType loadThatWasImposed)
|
||||
{
|
||||
Peer::pointer p = wp.lock ();
|
||||
Peer::pointer p = peerToPunish.lock ();
|
||||
|
||||
if (p)
|
||||
p->applyLoadCharge (l);
|
||||
if (p != nullptr)
|
||||
{
|
||||
p->applyLoadCharge (loadThatWasImposed);
|
||||
}
|
||||
}
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_PEER_H
|
||||
#define RIPPLE_PEER_H
|
||||
#ifndef RIPPLE_PEER_H_INCLUDED
|
||||
#define RIPPLE_PEER_H_INCLUDED
|
||||
|
||||
// VFALCO TODO Couldn't this be a struct?
|
||||
typedef std::pair <std::string, int> ipPort;
|
||||
@@ -15,8 +15,8 @@ class Peer
|
||||
, LeakChecked <Peer>
|
||||
{
|
||||
public:
|
||||
typedef boost::shared_ptr<Peer> pointer;
|
||||
typedef const boost::shared_ptr<Peer>& ref;
|
||||
typedef boost::shared_ptr <Peer> pointer;
|
||||
typedef pointer const& ref;
|
||||
|
||||
static int const psbGotHello = 0;
|
||||
static int const psbSentHello = 1;
|
||||
@@ -52,9 +52,6 @@ public:
|
||||
|
||||
virtual void detach (const char*, bool onIOStrand) = 0;
|
||||
|
||||
//virtual bool samePeer (Peer::ref p) = 0;
|
||||
//virtual bool samePeer (const Peer& p) = 0;
|
||||
|
||||
virtual void sendPacket (const PackedMessage::pointer& packet, bool onStrand) = 0;
|
||||
|
||||
virtual void sendGetPeers () = 0;
|
||||
@@ -62,7 +59,12 @@ public:
|
||||
virtual void applyLoadCharge (LoadType) = 0;
|
||||
|
||||
// VFALCO NOTE what's with this odd parameter passing? Why the static member?
|
||||
static void applyLoadCharge (const boost::weak_ptr<Peer>&, LoadType);
|
||||
//
|
||||
/** Adjust this peer's load balance based on the type of load imposed.
|
||||
|
||||
@note Formerly named punishPeer
|
||||
*/
|
||||
static void applyLoadCharge (boost::weak_ptr <Peer>& peerTOCharge, LoadType loadThatWasImposed);
|
||||
|
||||
virtual Json::Value getJson () = 0;
|
||||
|
||||
@@ -90,4 +92,3 @@ public:
|
||||
};
|
||||
|
||||
#endif
|
||||
// vim:ts=4
|
||||
|
||||
Reference in New Issue
Block a user