From 448e65fb4db07a0a7628234dfa0d84ffcaba2e50 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Sun, 30 Jun 2013 03:08:15 -0700 Subject: [PATCH] Rename SharedSingleton and move files around --- .../Builds/VisualStudio2012/beast.vcxproj | 33 ++++++------ .../VisualStudio2012/beast.vcxproj.filters | 39 +++++++-------- Subtrees/beast/TODO.txt | 50 +++++++++++++++++++ .../modules/beast_basics/beast_basics.cpp | 7 --- .../beast/modules/beast_basics/beast_basics.h | 2 - .../events/beast_OncePerSecond.cpp | 4 +- .../beast_basics/math/beast_MurmurHash.h | 2 +- .../memory/beast_GlobalFifoFreeStore.h | 4 +- .../memory/beast_GlobalPagedFreeStore.cpp | 2 +- .../memory/beast_GlobalPagedFreeStore.h | 2 +- .../threads/beast_GlobalThreadGroup.h | 6 +-- .../beast/modules/beast_core/beast_core.cpp | 6 +++ .../beast/modules/beast_core/beast_core.h | 11 ++-- .../beast_core/diagnostic/beast_FPUFlags.cpp | 2 +- .../maths}/beast_Interval.h | 0 .../memory/beast_SharedSingleton.h} | 24 ++++----- .../beast_core/native/beast_linux_Network.cpp | 1 - .../native/beast_posix_FPUFlags.cpp | 0 .../native/beast_win32_FPUFlags.cpp | 0 .../beast_Functional.h} | 2 +- TODO.txt | 46 ----------------- src/cpp/ripple/ripple_Main.cpp | 20 +++++--- 22 files changed, 135 insertions(+), 128 deletions(-) create mode 100644 Subtrees/beast/TODO.txt rename Subtrees/beast/modules/{beast_basics/math => beast_core/maths}/beast_Interval.h (100%) rename Subtrees/beast/modules/{beast_basics/memory/beast_RefCountedSingleton.h => beast_core/memory/beast_SharedSingleton.h} (88%) rename Subtrees/beast/modules/{beast_basics => beast_core}/native/beast_posix_FPUFlags.cpp (100%) rename Subtrees/beast/modules/{beast_basics => beast_core}/native/beast_win32_FPUFlags.cpp (100%) rename Subtrees/beast/modules/beast_core/{functional/beast_Bind.h => system/beast_Functional.h} (99%) diff --git a/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj b/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj index 9b1d39a8bf..ecb2bf124b 100644 --- a/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj +++ b/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj @@ -68,7 +68,6 @@ - @@ -78,7 +77,6 @@ - @@ -126,12 +124,12 @@ - + @@ -149,6 +147,7 @@ + @@ -174,6 +173,7 @@ + @@ -274,18 +274,6 @@ true true - - true - true - true - true - - - true - true - true - true - true true @@ -569,6 +557,12 @@ true true + + true + true + true + true + true true @@ -581,6 +575,12 @@ true true + + true + true + true + true + true true @@ -894,6 +894,9 @@ true + + + {73C5A0F0-7629-4DE7-9194-BE7AC6C19535} Win32Proj diff --git a/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj.filters b/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj.filters index d7d86413e1..8fb34fe73e 100644 --- a/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj.filters +++ b/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj.filters @@ -110,15 +110,9 @@ {9e850052-6ab7-4a65-911d-adfde81ceb5f} - - {811c5374-8959-4df9-aba9-a7e27b85046e} - {f58dddf7-fe43-49a2-8e57-91feba586119} - - {b70d6403-2d7a-4377-81ff-390830ab0276} - {69e28551-92ea-420b-a465-75ed248e3b59} @@ -482,9 +476,6 @@ beast_basics\functor - - beast_basics\math - beast_basics\math @@ -512,9 +503,6 @@ beast_basics\memory - - beast_basics\memory - beast_basics\threads @@ -557,9 +545,6 @@ beast_core\containers - - beast_core\functional - beast_core\memory @@ -617,6 +602,15 @@ beast_core\memory + + beast_core\memory + + + beast_core\system + + + beast_core\maths + @@ -892,12 +886,6 @@ beast_basics\memory - - beast_basics\native - - - beast_basics\native - beast_basics\threads @@ -955,5 +943,14 @@ beast_core\threads + + beast_core\native + + + beast_core\native + + + + \ No newline at end of file diff --git a/Subtrees/beast/TODO.txt b/Subtrees/beast/TODO.txt new file mode 100644 index 0000000000..e41f977fd9 --- /dev/null +++ b/Subtrees/beast/TODO.txt @@ -0,0 +1,50 @@ +-------------------------------------------------------------------------------- +BEAST TODO +-------------------------------------------------------------------------------- + +- Tidy up CacheLine, MemoryAlignment + +- Kill off beast_Singleton.h since it uses macros + +- Remove anything having to do with DLL builds like + BEAST_DLL, BEAST_DLL_BUILD, BEAST_DISABLE_DLL_ALLOCATORS + +- Fix FifoFreeStoreWithTLS reference counting bug + +- Implement a reasonable substitute for boost's thread_local_storage + +- Think about doing away with BEAST_CALLTYPE and BEAST_API + +- Decide if headers should just include BeastConfig.h instead of making the + host program do it. + +- Rename malloc/calloc JUCE members that conflict with the debug CRT from MSVC + +- Make beast::HashMap support assignment via operator[] + +- Reformat every Doxygen comment +- Fix Doxygen metatags +- update Beast Doxyfile + +- Rename include guards to boost style, e.g. BEAST_THROW_H_INCLUDED + +- Decide if we should get rid of AtomicCounter, AtomicFlag, AtomicPointer, AtomicState + +- Clean up CacheLine, StaticObject + +- Clean up ConcurrentObject + +- Rename ConcurrentState to SharedState or something? + +- Figure out what to do with ReadWriteLock, and NamedPipe which uses it? + +- Put BEAST_PUBLIC_FUNCTION in front of all loose functions + +- restructure the repo sources to look like this: + /Source/beast/beast_core/beast_core.h + etc... +- Put the BeastConfig.h at the root of the repo. +- Make sure the template BeastConfig.h is included in the Doxyfile + +- Implement robust key/value database with bulk write + diff --git a/Subtrees/beast/modules/beast_basics/beast_basics.cpp b/Subtrees/beast/modules/beast_basics/beast_basics.cpp index ef990ae610..ca2b3fca2b 100644 --- a/Subtrees/beast/modules/beast_basics/beast_basics.cpp +++ b/Subtrees/beast/modules/beast_basics/beast_basics.cpp @@ -62,13 +62,6 @@ namespace beast #include "threads/beast_ThreadGroup.cpp" #include "threads/beast_ThreadWithCallQueue.cpp" -#if BEAST_WINDOWS -#include "native/beast_win32_FPUFlags.cpp" - -#else -#include "native/beast_posix_FPUFlags.cpp" - -#endif } #if BEAST_MSVC diff --git a/Subtrees/beast/modules/beast_basics/beast_basics.h b/Subtrees/beast/modules/beast_basics/beast_basics.h index cfbfdfaa28..d323cab858 100644 --- a/Subtrees/beast/modules/beast_basics/beast_basics.h +++ b/Subtrees/beast/modules/beast_basics/beast_basics.h @@ -248,11 +248,9 @@ namespace beast #include "functor/beast_Function.h" #include "diagnostic/beast_CatchAny.h" #include "events/beast_OncePerSecond.h" -#include "math/beast_Interval.h" #include "math/beast_Math.h" #include "math/beast_MurmurHash.h" #include "memory/beast_AllocatedBy.h" -#include "memory/beast_RefCountedSingleton.h" #include "memory/beast_PagedFreeStore.h" #include "memory/beast_GlobalPagedFreeStore.h" #include "memory/beast_FifoFreeStoreWithTLS.h" diff --git a/Subtrees/beast/modules/beast_basics/events/beast_OncePerSecond.cpp b/Subtrees/beast/modules/beast_basics/events/beast_OncePerSecond.cpp index 8311b397fb..7f5bbda7e6 100644 --- a/Subtrees/beast/modules/beast_basics/events/beast_OncePerSecond.cpp +++ b/Subtrees/beast/modules/beast_basics/events/beast_OncePerSecond.cpp @@ -18,12 +18,12 @@ //============================================================================== class OncePerSecond::TimerSingleton - : public RefCountedSingleton + : public SharedSingleton , private InterruptibleThread::EntryPoint { private: TimerSingleton () - : RefCountedSingleton ( + : SharedSingleton ( SingletonLifetime::persistAfterCreation) , m_thread ("Once Per Second") { diff --git a/Subtrees/beast/modules/beast_basics/math/beast_MurmurHash.h b/Subtrees/beast/modules/beast_basics/math/beast_MurmurHash.h index f412bff897..0f1e8c2385 100644 --- a/Subtrees/beast/modules/beast_basics/math/beast_MurmurHash.h +++ b/Subtrees/beast/modules/beast_basics/math/beast_MurmurHash.h @@ -22,7 +22,7 @@ // Original source code links in .cpp file -// This file depends on some Juce declarations and defines +// This file depends on some Beast declarations and defines namespace Murmur { diff --git a/Subtrees/beast/modules/beast_basics/memory/beast_GlobalFifoFreeStore.h b/Subtrees/beast/modules/beast_basics/memory/beast_GlobalFifoFreeStore.h index 6b159d38c6..987a584cde 100644 --- a/Subtrees/beast/modules/beast_basics/memory/beast_GlobalFifoFreeStore.h +++ b/Subtrees/beast/modules/beast_basics/memory/beast_GlobalFifoFreeStore.h @@ -27,7 +27,7 @@ @ingroup beast_concurrent */ template -class GlobalFifoFreeStore : public RefCountedSingleton > +class GlobalFifoFreeStore : public SharedSingleton > { public: inline void* allocate (size_t bytes) @@ -47,7 +47,7 @@ public: private: GlobalFifoFreeStore () - : RefCountedSingleton > + : SharedSingleton > (SingletonLifetime::persistAfterCreation) { } diff --git a/Subtrees/beast/modules/beast_basics/memory/beast_GlobalPagedFreeStore.cpp b/Subtrees/beast/modules/beast_basics/memory/beast_GlobalPagedFreeStore.cpp index 1b3cd6d504..1074728c51 100644 --- a/Subtrees/beast/modules/beast_basics/memory/beast_GlobalPagedFreeStore.cpp +++ b/Subtrees/beast/modules/beast_basics/memory/beast_GlobalPagedFreeStore.cpp @@ -27,7 +27,7 @@ static const size_t globalPageBytes = 8 * 1024; } GlobalPagedFreeStore::GlobalPagedFreeStore () - : RefCountedSingleton (SingletonLifetime::persistAfterCreation) + : SharedSingleton (SingletonLifetime::persistAfterCreation) , m_allocator (globalPageBytes) { } diff --git a/Subtrees/beast/modules/beast_basics/memory/beast_GlobalPagedFreeStore.h b/Subtrees/beast/modules/beast_basics/memory/beast_GlobalPagedFreeStore.h index 1adc9b595f..17c88af013 100644 --- a/Subtrees/beast/modules/beast_basics/memory/beast_GlobalPagedFreeStore.h +++ b/Subtrees/beast/modules/beast_basics/memory/beast_GlobalPagedFreeStore.h @@ -27,7 +27,7 @@ @ingroup beast_concurrent */ class BEAST_API GlobalPagedFreeStore - : public RefCountedSingleton + : public SharedSingleton , LeakChecked { private: diff --git a/Subtrees/beast/modules/beast_basics/threads/beast_GlobalThreadGroup.h b/Subtrees/beast/modules/beast_basics/threads/beast_GlobalThreadGroup.h index 995bbcce3b..38bf7dd013 100644 --- a/Subtrees/beast/modules/beast_basics/threads/beast_GlobalThreadGroup.h +++ b/Subtrees/beast/modules/beast_basics/threads/beast_GlobalThreadGroup.h @@ -29,13 +29,13 @@ @ingroup beast_concurrent */ class BEAST_API GlobalThreadGroup : public ThreadGroup, - public RefCountedSingleton + public SharedSingleton { private: - friend class RefCountedSingleton ; + friend class SharedSingleton ; GlobalThreadGroup () - : RefCountedSingleton ( + : SharedSingleton ( SingletonLifetime::persistAfterCreation) { } diff --git a/Subtrees/beast/modules/beast_core/beast_core.cpp b/Subtrees/beast/modules/beast_core/beast_core.cpp index 55a8ab682c..5a18ba707d 100644 --- a/Subtrees/beast/modules/beast_core/beast_core.cpp +++ b/Subtrees/beast/modules/beast_core/beast_core.cpp @@ -221,6 +221,12 @@ namespace beast #include "native/beast_osx_ObjCHelpers.h" #endif +#if BEAST_WINDOWS +#include "native/beast_win32_FPUFlags.cpp" +#else +#include "native/beast_posix_FPUFlags.cpp" +#endif + #if BEAST_ANDROID #include "native/beast_android_JNIHelpers.h" #endif diff --git a/Subtrees/beast/modules/beast_core/beast_core.h b/Subtrees/beast/modules/beast_core/beast_core.h index 8510f7f64d..908f4f27ff 100644 --- a/Subtrees/beast/modules/beast_core/beast_core.h +++ b/Subtrees/beast/modules/beast_core/beast_core.h @@ -209,13 +209,10 @@ namespace beast #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" @@ -247,12 +244,12 @@ namespace beast #include "files/beast_FileSearchPath.h" #include "files/beast_MemoryMappedFile.h" #include "files/beast_TemporaryFile.h" -#include "functional/beast_Bind.h" #include "json/beast_JSON.h" #include "logging/beast_FileLogger.h" #include "logging/beast_Logger.h" #include "maths/beast_BigInteger.h" #include "maths/beast_Expression.h" +#include "maths/beast_Interval.h" #include "maths/beast_MathsFunctions.h" #include "maths/beast_Random.h" #include "maths/beast_Range.h" @@ -263,6 +260,9 @@ namespace beast #include "memory/beast_OptionalScopedPointer.h" #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_Singleton.h" #include "memory/beast_WeakReference.h" #include "memory/beast_MemoryAlignment.h" @@ -283,6 +283,7 @@ namespace beast #include "streams/beast_MemoryOutputStream.h" #include "streams/beast_OutputStream.h" #include "streams/beast_SubregionStream.h" +#include "system/beast_Functional.h" #include "system/beast_PlatformDefs.h" #include "system/beast_StandardHeader.h" #include "system/beast_SystemStats.h" @@ -310,13 +311,11 @@ namespace beast #include "threads/beast_ScopedLock.h" #include "threads/beast_ScopedReadLock.h" #include "threads/beast_ScopedWriteLock.h" -#include "threads/beast_SpinLock.h" #include "threads/beast_ThreadLocalValue.h" #include "threads/beast_ThreadPool.h" #include "threads/beast_TimeSliceThread.h" #include "threads/beast_WaitableEvent.h" #include "time/beast_PerformanceCounter.h" -#include "time/beast_PerformedAtExit.h" #include "time/beast_RelativeTime.h" #include "time/beast_Time.h" #include "unit_tests/beast_UnitTest.h" diff --git a/Subtrees/beast/modules/beast_core/diagnostic/beast_FPUFlags.cpp b/Subtrees/beast/modules/beast_core/diagnostic/beast_FPUFlags.cpp index 8e83e14864..39eb589cfc 100644 --- a/Subtrees/beast/modules/beast_core/diagnostic/beast_FPUFlags.cpp +++ b/Subtrees/beast/modules/beast_core/diagnostic/beast_FPUFlags.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -void FPUFlags::clearUnsetFlagsFrom (const FPUFlags& flags) +void FPUFlags::clearUnsetFlagsFrom (FPUFlags const& flags) { if (!flags.getMaskNaNs ().is_set ()) m_maskNaNs.clear (); diff --git a/Subtrees/beast/modules/beast_basics/math/beast_Interval.h b/Subtrees/beast/modules/beast_core/maths/beast_Interval.h similarity index 100% rename from Subtrees/beast/modules/beast_basics/math/beast_Interval.h rename to Subtrees/beast/modules/beast_core/maths/beast_Interval.h diff --git a/Subtrees/beast/modules/beast_basics/memory/beast_RefCountedSingleton.h b/Subtrees/beast/modules/beast_core/memory/beast_SharedSingleton.h similarity index 88% rename from Subtrees/beast/modules/beast_basics/memory/beast_RefCountedSingleton.h rename to Subtrees/beast/modules/beast_core/memory/beast_SharedSingleton.h index cb8e3d2a69..ac96ae3bf0 100644 --- a/Subtrees/beast/modules/beast_basics/memory/beast_RefCountedSingleton.h +++ b/Subtrees/beast/modules/beast_core/memory/beast_SharedSingleton.h @@ -28,7 +28,7 @@ class Object must provide the function `Object* Object::createInstance()` - @class RefCountedSingleton + @class SharedSingleton @ingroup beast_core */ /** @{ */ @@ -42,7 +42,7 @@ public: // - ville // - /** Construction options for RefCountedSingleton + /** Construction options for SharedSingleton @ingroup beast_core */ @@ -66,7 +66,7 @@ public: //------------------------------------------------------------------------------ template -class RefCountedSingleton +class SharedSingleton : public SingletonLifetime , private PerformedAtExit { @@ -77,7 +77,7 @@ protected: @param lifetime The lifetime management option. */ - explicit RefCountedSingleton (Lifetime const lifetime) + explicit SharedSingleton (Lifetime const lifetime) : m_lifetime (lifetime) { bassert (s_instance == nullptr); @@ -94,7 +94,7 @@ protected: *s_created = true; } - virtual ~RefCountedSingleton () + virtual ~SharedSingleton () { bassert (s_instance == nullptr); } @@ -181,20 +181,20 @@ private: private: static Object* s_instance; - static Static::Storage > s_mutex; - static Static::Storage > s_created; + static Static::Storage > s_mutex; + static Static::Storage > s_created; }; /** @{ */ template -Object* RefCountedSingleton ::s_instance; +Object* SharedSingleton ::s_instance; template -Static::Storage ::LockType, RefCountedSingleton > -RefCountedSingleton ::s_mutex; +Static::Storage ::LockType, SharedSingleton > +SharedSingleton ::s_mutex; template -Static::Storage > -RefCountedSingleton ::s_created; +Static::Storage > +SharedSingleton ::s_created; #endif diff --git a/Subtrees/beast/modules/beast_core/native/beast_linux_Network.cpp b/Subtrees/beast/modules/beast_core/native/beast_linux_Network.cpp index 69677f6db4..137718093c 100644 --- a/Subtrees/beast/modules/beast_core/native/beast_linux_Network.cpp +++ b/Subtrees/beast/modules/beast_core/native/beast_linux_Network.cpp @@ -65,7 +65,6 @@ bool Process::openEmailWithAttachments (const String& /* targetEmailAddress */, class WebInputStream : public InputStream , LeakChecked - , Uncopyable { public: WebInputStream (const String& address_, bool isPost_, const MemoryBlock& postData_, diff --git a/Subtrees/beast/modules/beast_basics/native/beast_posix_FPUFlags.cpp b/Subtrees/beast/modules/beast_core/native/beast_posix_FPUFlags.cpp similarity index 100% rename from Subtrees/beast/modules/beast_basics/native/beast_posix_FPUFlags.cpp rename to Subtrees/beast/modules/beast_core/native/beast_posix_FPUFlags.cpp diff --git a/Subtrees/beast/modules/beast_basics/native/beast_win32_FPUFlags.cpp b/Subtrees/beast/modules/beast_core/native/beast_win32_FPUFlags.cpp similarity index 100% rename from Subtrees/beast/modules/beast_basics/native/beast_win32_FPUFlags.cpp rename to Subtrees/beast/modules/beast_core/native/beast_win32_FPUFlags.cpp diff --git a/Subtrees/beast/modules/beast_core/functional/beast_Bind.h b/Subtrees/beast/modules/beast_core/system/beast_Functional.h similarity index 99% rename from Subtrees/beast/modules/beast_core/functional/beast_Bind.h rename to Subtrees/beast/modules/beast_core/system/beast_Functional.h index a7a697eea1..792a1422e8 100644 --- a/Subtrees/beast/modules/beast_core/functional/beast_Bind.h +++ b/Subtrees/beast/modules/beast_core/system/beast_Functional.h @@ -324,7 +324,7 @@ using boost::placeholders::_20; #else -#error Unknown bind source in beast_Bind.h +#error Unknown bind source in beast_Functional.h #endif diff --git a/TODO.txt b/TODO.txt index fea5d70589..ca34e06d3e 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,49 +1,3 @@ --------------------------------------------------------------------------------- -BEAST TODO --------------------------------------------------------------------------------- - -- Remove anything having to do with DLL builds like - BEAST_DLL, BEAST_DLL_BUILD, BEAST_DISABLE_DLL_ALLOCATORS - -- Fix FifoFreeStoreWithTLS reference counting bug - -- Implement a reasonable substitute for boost's thread_local_storage - -- Think about doing away with BEAST_CALLTYPE and BEAST_API - -- Decide if headers should just include BeastConfig.h instead of making the - host program do it. - -- Rename malloc/calloc JUCE members that conflict with the debug CRT from MSVC - -- Make beast::HashMap support assignment via operator[] - -- Reformat every Doxygen comment -- Fix Doxygen metatags -- update Beast Doxyfile - -- Rename include guards to boost style, e.g. BEAST_THROW_H_INCLUDED - -- Decide if we should get rid of AtomicCounter, AtomicFlag, AtomicPointer, AtomicState - -- Clean up CacheLine, StaticObject - -- Clean up ConcurrentObject - -- Rename ConcurrentState to SharedState or something? - -- Figure out what to do with ReadWriteLock, and NamedPipe which uses it? - -- Put BEAST_PUBLIC_FUNCTION in front of all loose functions - -- restructure the repo sources to look like this: - /Source/beast/beast_core/beast_core.h - etc... -- Put the BeastConfig.h at the root of the repo. -- Make sure the template BeastConfig.h is included in the Doxyfile - -- Implement robust key/value database with bulk write - -------------------------------------------------------------------------------- RIPPLE TODO -------------------------------------------------------------------------------- diff --git a/src/cpp/ripple/ripple_Main.cpp b/src/cpp/ripple/ripple_Main.cpp index d8612bef04..97da79deff 100644 --- a/src/cpp/ripple/ripple_Main.cpp +++ b/src/cpp/ripple/ripple_Main.cpp @@ -124,20 +124,28 @@ int rippleMain (int argc, char** argv) // // Checks the heap at every allocation and deallocation (slow). + // Debug::setAlwaysCheckHeap (false); // Keeps freed memory blocks and fills them with a guard value. + // Debug::setHeapDelayedFree (false); // At exit, reports all memory blocks which have not been freed. + // +#if 1 Debug::setHeapReportLeaks (false); -#if 0 -// This is some temporary leak checking test code -ThreadWithCallQueue t ("test"); -GlobalPagedFreeStore::getInstance (); -t.start (); -return 0; +#else + // This is some temporary leak checking test code + // + Debug::setHeapReportLeaks (true); + + //ThreadWithCallQueue t ("test"); + //GlobalPagedFreeStore::getInstance (); + //t.start (); + + return 0; #endif using namespace std;