diff --git a/Builds/QtCreator/rippled.pro b/Builds/QtCreator/rippled.pro
index 957370a493..d90b383b5c 100644
--- a/Builds/QtCreator/rippled.pro
+++ b/Builds/QtCreator/rippled.pro
@@ -61,6 +61,7 @@ UI_HEADERS_DIR += ../../modules/ripple_basics
SOURCES += \
../../Subtrees/beast/modules/beast_asio/beast_asio.cpp \
../../Subtrees/beast/modules/beast_basics/beast_basics.cpp \
+ ../../Subtrees/beast/modules/beast_boost/beast_boost.cpp \
../../Subtrees/beast/modules/beast_core/beast_core.cpp \
../../Subtrees/beast/modules/beast_crypto/beast_crypto.cpp \
../../Subtrees/beast/modules/beast_db/beast_db.cpp \
diff --git a/Builds/VisualStudio2012/RippleD.vcxproj b/Builds/VisualStudio2012/RippleD.vcxproj
index 9a79dacd89..203b29f495 100644
--- a/Builds/VisualStudio2012/RippleD.vcxproj
+++ b/Builds/VisualStudio2012/RippleD.vcxproj
@@ -1021,6 +1021,7 @@
+
diff --git a/Builds/VisualStudio2012/RippleD.vcxproj.filters b/Builds/VisualStudio2012/RippleD.vcxproj.filters
index cbc15ab178..470020139f 100644
--- a/Builds/VisualStudio2012/RippleD.vcxproj.filters
+++ b/Builds/VisualStudio2012/RippleD.vcxproj.filters
@@ -891,6 +891,9 @@
[1] Ripple\ripple_app\boost
+
+ [0] Subtrees\beast
+
diff --git a/SConstruct b/SConstruct
index 443fb52733..37cd9e0fd9 100644
--- a/SConstruct
+++ b/SConstruct
@@ -133,7 +133,7 @@ else:
COMPILED_FILES.extend([
'Subtrees/beast/modules/beast_asio/beast_asio.cpp',
'Subtrees/beast/modules/beast_basics/beast_basics.cpp',
- # 'Subtrees/beast/modules/beast_core/beast_core.cpp',
+ 'Subtrees/beast/modules/beast_boost/beast_boost.cpp',
'Subtrees/beast/modules/beast_crypto/beast_crypto.cpp',
'Subtrees/beast/modules/beast_db/beast_db.cpp',
'Subtrees/beast/modules/beast_sqdb/beast_sqdb.cpp',
diff --git a/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj b/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj
index 23b9c40448..36b1a50a48 100644
--- a/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj
+++ b/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj
@@ -116,17 +116,17 @@
-
-
+
+
@@ -159,6 +159,7 @@
+
@@ -235,7 +236,6 @@
-
@@ -248,9 +248,11 @@
+
+
@@ -258,6 +260,13 @@
+
+
+
+
+
+
+
@@ -466,12 +475,6 @@
true
true
-
- true
- true
- true
- true
-
true
true
@@ -496,6 +499,7 @@
true
true
+
true
@@ -915,12 +919,6 @@
true
true
-
- true
- true
- true
- true
-
true
true
@@ -969,6 +967,12 @@
true
true
+
+ true
+ true
+ true
+ true
+
true
true
@@ -993,6 +997,12 @@
true
true
+
+ true
+ true
+ true
+ true
+
true
true
diff --git a/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj.filters b/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj.filters
index 08346ee209..28f89bd5a9 100644
--- a/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj.filters
+++ b/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj.filters
@@ -161,6 +161,21 @@
{beb81776-4aad-401d-8826-81478dbbf30b}
+
+ {0eac8b8d-7049-4eda-b6b4-53194d336a97}
+
+
+ {1e6959ed-fcb9-4a3b-ac5a-eb26973e21f6}
+
+
+ {493db217-b3e4-4b08-97b2-a2d753cc8c35}
+
+
+ {1b2e8962-c087-4453-8107-7077c2de5846}
+
+
+ {91538dcf-b219-4c80-9861-bb4949089775}
+
@@ -545,9 +560,6 @@
beast_basics\threads
-
- beast_basics\threads
-
beast_basics\threads
@@ -632,9 +644,6 @@
beast_core\time
-
- beast_basics\threads
-
beast_basics\events
@@ -869,8 +878,41 @@
beast_asio\handshake
-
- beast_core\text
+
+ beast_core\diagnostic
+
+
+ beast_boost
+
+
+ beast_core\threads
+
+
+ beast_core\threads
+
+
+ beast_boost\traits
+
+
+ beast_core\thread
+
+
+ beast_core\thread
+
+
+ beast_core\thread\detail
+
+
+ beast_core\thread\detail
+
+
+ beast_core\thread\impl
+
+
+ beast_core\thread\impl
+
+
+ beast_core\thread\impl
@@ -1150,9 +1192,6 @@
beast_basics\threads
-
- beast_basics\threads
-
beast_basics\threads
@@ -1339,8 +1378,14 @@
beast_asio\async
-
- beast_core\text
+
+ beast_boost
+
+
+ beast_core\threads
+
+
+ beast_core\thread\impl
diff --git a/Subtrees/beast/modules/beast_basics/beast_basics.cpp b/Subtrees/beast/modules/beast_basics/beast_basics.cpp
index 099cbe6027..18f7a73774 100644
--- a/Subtrees/beast/modules/beast_basics/beast_basics.cpp
+++ b/Subtrees/beast/modules/beast_basics/beast_basics.cpp
@@ -53,7 +53,6 @@ namespace beast
#include "threads/beast_Listeners.cpp"
#include "threads/beast_ManualCallQueue.cpp"
#include "threads/beast_ParallelFor.cpp"
-#include "threads/beast_ReadWriteMutex.cpp"
#include "threads/beast_ThreadGroup.cpp"
#include "threads/beast_ThreadWithCallQueue.cpp"
#include "threads/beast_Workers.cpp"
diff --git a/Subtrees/beast/modules/beast_basics/beast_basics.h b/Subtrees/beast/modules/beast_basics/beast_basics.h
index d9a5b78ba7..940732e9a7 100644
--- a/Subtrees/beast/modules/beast_basics/beast_basics.h
+++ b/Subtrees/beast/modules/beast_basics/beast_basics.h
@@ -259,10 +259,8 @@ namespace beast
#include "threads/beast_Semaphore.h"
#include "threads/beast_SerialFor.h"
#include "threads/beast_InterruptibleThread.h"
-#include "threads/beast_ReadWriteMutex.h"
#include "threads/beast_ThreadGroup.h"
#include "threads/beast_CallQueue.h"
-#include "threads/beast_SharedData.h"
#include "threads/beast_GlobalThreadGroup.h"
#include "threads/beast_Listeners.h"
#include "threads/beast_ManualCallQueue.h"
diff --git a/Subtrees/beast/modules/beast_boost/.gitignore b/Subtrees/beast/modules/beast_boost/.gitignore
index 4d99b61908..5a31723b02 100644
--- a/Subtrees/beast/modules/beast_boost/.gitignore
+++ b/Subtrees/beast/modules/beast_boost/.gitignore
@@ -1,2 +1 @@
/boost-subtree
-*.cpp
diff --git a/Subtrees/beast/modules/beast_boost/beast_boost.cpp b/Subtrees/beast/modules/beast_boost/beast_boost.cpp
new file mode 100644
index 0000000000..7a58ced01f
--- /dev/null
+++ b/Subtrees/beast/modules/beast_boost/beast_boost.cpp
@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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.
+*/
+//==============================================================================
+
+#include "BeastConfig.h"
+
+#include "beast_boost.h"
+
+namespace beast
+{
+
+
+
+}
diff --git a/Subtrees/beast/modules/beast_boost/beast_boost.h b/Subtrees/beast/modules/beast_boost/beast_boost.h
new file mode 100644
index 0000000000..6e49a8a358
--- /dev/null
+++ b/Subtrees/beast/modules/beast_boost/beast_boost.h
@@ -0,0 +1,43 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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_BOOST_H_INCLUDED
+#define BEAST_BOOST_H_INCLUDED
+
+// Adds boost-specific features to beast.
+
+#include
+
+// lockable_traits was added in 1.53.0
+#ifndef BEAST_BOOST_HAS_LOCKABLES
+# if BOOST_VERSION >= 105300
+# define BEAST_BOOST_HAS_LOCKABLES 1
+# else
+# define BEAST_BOOST_HAS_LOCKABLES 0
+# endif
+#endif
+#if BEAST_BOOST_HAS_LOCKABLES
+# include
+#endif
+
+#if BEAST_BOOST_HAS_LOCKABLES
+# include "traits/beast_BoostLockableTraits.h"
+#endif
+
+#endif
diff --git a/Subtrees/beast/modules/beast_boost/traits/beast_BoostLockableTraits.h b/Subtrees/beast/modules/beast_boost/traits/beast_BoostLockableTraits.h
new file mode 100644
index 0000000000..7e9803b510
--- /dev/null
+++ b/Subtrees/beast/modules/beast_boost/traits/beast_BoostLockableTraits.h
@@ -0,0 +1,125 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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_BOOSTLOCKABLERAITS_H_INCLUDED
+#define BEAST_BOOSTLOCKABLERAITS_H_INCLUDED
+
+// Adds beast specializations for boost lockables.
+
+// beast forward declarations
+
+namespace beast
+{
+
+class CriticalSection;
+
+template
+class TrackedMutex;
+
+template
+class UntrackedMutex;
+
+}
+
+//------------------------------------------------------------------------------
+
+// boost Mutex concepts
+//
+// http://www.boost.org/doc/libs/1_54_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_concepts
+
+namespace boost
+{
+
+namespace sync
+{
+
+//------------------------------------------------------------------------------
+//
+// CriticalSection
+//
+
+// BasicLockable
+//
+template <>
+struct is_basic_lockable
+ : public boost::true_type { };
+
+// Lockable
+//
+template <>
+struct is_lockable
+ : public boost::true_type { };
+
+// RecursiveLockable
+//
+template <>
+struct is_recursive_mutex_sur_parole
+ : public boost::true_type { };
+
+//------------------------------------------------------------------------------
+//
+// TrackedMutex <>
+//
+
+// BasicLockable
+//
+template
+class is_basic_lockable >
+ : public boost::sync::is_basic_lockable { };
+
+// Lockable
+//
+template
+class is_lockable >
+ : public boost::sync::is_lockable { };
+
+// RecursiveLockable
+//
+template
+struct is_recursive_mutex_sur_parole >
+ : public boost::true_type { };
+
+//------------------------------------------------------------------------------
+//
+// UntrackedMutex <>
+//
+
+// BasicLockable
+//
+template
+class is_basic_lockable >
+ : public boost::sync::is_basic_lockable { };
+
+// Lockable
+//
+template
+class is_lockable >
+ : public boost::sync::is_lockable { };
+
+// RecursiveLockable
+//
+template
+struct is_recursive_mutex_sur_parole >
+ : public boost::true_type { };
+
+}
+
+}
+
+#endif
diff --git a/Subtrees/beast/modules/beast_core/beast_core.cpp b/Subtrees/beast/modules/beast_core/beast_core.cpp
index b90b480d03..346adf76df 100644
--- a/Subtrees/beast/modules/beast_core/beast_core.cpp
+++ b/Subtrees/beast/modules/beast_core/beast_core.cpp
@@ -204,8 +204,11 @@ namespace beast
#include "text/beast_StringPool.cpp"
#include "text/beast_TextDiff.cpp"
+#include "thread/impl/TrackedMutex.cpp"
+
#include "threads/beast_ChildProcess.cpp"
#include "threads/beast_ReadWriteLock.cpp"
+#include "threads/beast_ReadWriteMutex.cpp"
#include "threads/beast_SpinDelay.cpp"
#include "threads/beast_Thread.cpp"
#include "threads/beast_ThreadPool.cpp"
diff --git a/Subtrees/beast/modules/beast_core/beast_core.h b/Subtrees/beast/modules/beast_core/beast_core.h
index 5cc6d85086..c70f009db1 100644
--- a/Subtrees/beast/modules/beast_core/beast_core.h
+++ b/Subtrees/beast/modules/beast_core/beast_core.h
@@ -198,6 +198,8 @@ namespace beast
#include "system/beast_PlatformDefs.h"
#include "system/beast_TargetPlatform.h"
+
+#include "diagnostic/beast_Throw.h"
#include "system/beast_Functional.h"
#include "maths/beast_MathsFunctions.h"
@@ -206,6 +208,7 @@ namespace beast
#include "memory/beast_AtomicFlag.h"
#include "memory/beast_AtomicPointer.h"
#include "memory/beast_AtomicState.h"
+#include "containers/beast_List.h"
#include "containers/beast_LockFreeStack.h"
#include "threads/beast_SpinDelay.h"
#include "memory/beast_StaticObject.h"
@@ -213,12 +216,26 @@ namespace beast
#include "text/beast_String.h"
+#include "memory/beast_MemoryAlignment.h"
+#include "memory/beast_CacheLine.h"
#include "threads/beast_CriticalSection.h"
-#include "diagnostic/beast_FatalError.h"
+#include "threads/beast_ReadWriteMutex.h"
+#include "threads/beast_SharedData.h"
#include "diagnostic/beast_SafeBool.h"
+#include "time/beast_PerformedAtExit.h"
+#include "diagnostic/beast_LeakChecked.h"
+#include "threads/beast_WaitableEvent.h"
+#include "threads/beast_Thread.h"
+#include "threads/beast_SpinLock.h"
+#include "threads/beast_ThreadLocalValue.h"
+
+#include "thread/MutexTraits.h"
+#include "containers/beast_Array.h"
+#include "text/beast_StringArray.h"
+#include "thread/TrackedMutex.h"
+#include "diagnostic/beast_FatalError.h"
#include "diagnostic/beast_Error.h"
#include "diagnostic/beast_Debug.h"
-#include "diagnostic/beast_Throw.h"
#include "text/beast_CharacterFunctions.h"
#include "text/beast_CharPointer_ASCII.h"
@@ -228,23 +245,18 @@ namespace beast
#include "text/beast_LexicalCast.h"
#include "memory/beast_ContainerDeletePolicy.h"
-#include "time/beast_PerformedAtExit.h"
-#include "diagnostic/beast_LeakChecked.h"
#include "memory/beast_ByteOrder.h"
#include "memory/beast_ByteSwap.h"
#include "maths/beast_uint24.h"
#include "logging/beast_Logger.h"
-#include "threads/beast_Thread.h"
#include "diagnostic/beast_FPUFlags.h"
#include "diagnostic/beast_ProtectedCall.h"
#include "containers/beast_AbstractFifo.h"
-#include "containers/beast_Array.h"
#include "containers/beast_ArrayAllocationBase.h"
#include "containers/beast_DynamicObject.h"
#include "containers/beast_ElementComparator.h"
#include "maths/beast_Random.h"
#include "containers/beast_HashMap.h"
-#include "containers/beast_List.h"
#include "containers/beast_LinkedListPointer.h"
#include "containers/beast_LockFreeQueue.h"
#include "containers/beast_NamedValueSet.h"
@@ -281,11 +293,8 @@ namespace beast
#include "memory/beast_OptionalScopedPointer.h"
#include "memory/beast_SharedObject.h"
#include "memory/beast_ScopedPointer.h"
-#include "threads/beast_SpinLock.h"
#include "memory/beast_SharedSingleton.h"
#include "memory/beast_WeakReference.h"
-#include "memory/beast_MemoryAlignment.h"
-#include "memory/beast_CacheLine.h"
#include "memory/beast_RecycledObjectPool.h"
#include "misc/beast_Main.h"
#include "misc/beast_Result.h"
@@ -309,7 +318,6 @@ namespace beast
#include "text/beast_Identifier.h"
#include "text/beast_LocalisedStrings.h"
#include "text/beast_NewLine.h"
-#include "text/beast_StringArray.h"
#include "diagnostic/beast_SemanticVersion.h"
#include "text/beast_StringPairArray.h"
#include "text/beast_StringPool.h"
@@ -323,10 +331,8 @@ namespace beast
#include "threads/beast_ScopedLock.h"
#include "threads/beast_ScopedReadLock.h"
#include "threads/beast_ScopedWriteLock.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_RelativeTime.h"
#include "time/beast_Time.h"
@@ -338,6 +344,8 @@ namespace beast
#include "zip/beast_GZIPDecompressorInputStream.h"
#include "zip/beast_ZipFile.h"
+#include "diagnostic/MeasureFunctionCallTime.h"
+
}
#ifdef _CRTDBG_MAP_ALLOC
diff --git a/Subtrees/beast/modules/beast_core/diagnostic/MeasureFunctionCallTime.h b/Subtrees/beast/modules/beast_core/diagnostic/MeasureFunctionCallTime.h
new file mode 100644
index 0000000000..99efe3412b
--- /dev/null
+++ b/Subtrees/beast/modules/beast_core/diagnostic/MeasureFunctionCallTime.h
@@ -0,0 +1,80 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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_CORE_DIAGNOSTIC_MEASUREFUNCTIONCALLTIME_H_INCLUDED
+#define BEAST_CORE_DIAGNOSTIC_MEASUREFUNCTIONCALLTIME_H_INCLUDED
+
+/** Measures the speed of invoking a function. */
+/** @{ */
+template
+double measureFunctionCallTime (Function f)
+{
+ int64 const startTime (Time::getHighResolutionTicks ());
+ f ();
+ return Time::highResolutionTicksToSeconds (
+ Time::getHighResolutionTicks () - startTime);
+}
+
+#if 0
+template
+double measureFunctionCallTime (Function f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8)
+{
+ int64 const startTime (Time::getHighResolutionTicks ());
+ f (p1, p2, p3, p4, p5 ,p6 ,p7 ,p8);
+ return Time::highResolutionTicksToSeconds (
+ Time::getHighResolutionTicks () - startTime);
+}
+
+template
+double measureFunctionCallTime (Function f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8)
+{
+ int64 const startTime (Time::getHighResolutionTicks ());
+ f (p1, p2, p3, p4, p5 ,p6 ,p7 ,p8);
+ return Time::highResolutionTicksToSeconds (
+ Time::getHighResolutionTicks () - startTime);
+}
+
+template
+double measureFunctionCallTime (Function f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8)
+{
+ int64 const startTime (Time::getHighResolutionTicks ());
+ f (p1, p2, p3, p4, p5 ,p6 ,p7 ,p8);
+ return Time::highResolutionTicksToSeconds (
+ Time::getHighResolutionTicks () - startTime);
+}
+
+template
+double measureFunctionCallTime (Function f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8)
+{
+ int64 const startTime (Time::getHighResolutionTicks ());
+ f (p1, p2, p3, p4, p5 ,p6 ,p7 ,p8);
+ return Time::highResolutionTicksToSeconds (
+ Time::getHighResolutionTicks () - startTime);
+}
+#endif
+
+#endif
diff --git a/Subtrees/beast/modules/beast_core/diagnostic/beast_Debug.cpp b/Subtrees/beast/modules/beast_core/diagnostic/beast_Debug.cpp
index e52ea11a67..488e030d31 100644
--- a/Subtrees/beast/modules/beast_core/diagnostic/beast_Debug.cpp
+++ b/Subtrees/beast/modules/beast_core/diagnostic/beast_Debug.cpp
@@ -118,9 +118,36 @@ void checkHeap ()
//------------------------------------------------------------------------------
-const String getFileNameFromPath (const char* sourceFileName)
+String getSourceLocation (char const* fileName, int lineNumber,
+ int numberOfParents)
{
- return File::createFileWithoutCheckingPath (sourceFileName).getFileName ();
+ return getFileNameFromPath (fileName, numberOfParents) +
+ "(" + String::fromNumber (lineNumber) + ")";
+}
+
+String getFileNameFromPath (const char* sourceFileName, int numberOfParents)
+{
+ String fullPath (sourceFileName);
+
+#if BEAST_WINDOWS
+ // Convert everything to forward slash
+ fullPath = fullPath.replaceCharacter ('\\', '/');
+#endif
+
+ String path;
+
+ int chopPoint = fullPath.lastIndexOfChar ('/');
+ path = fullPath.substring (chopPoint + 1);
+
+ while (chopPoint >= 0 && numberOfParents > 0)
+ {
+ --numberOfParents;
+ fullPath = fullPath.substring (0, chopPoint);
+ chopPoint = fullPath.lastIndexOfChar ('/');
+ path = fullPath.substring (chopPoint + 1) + '/' + path;
+ }
+
+ return path;
}
// Returns a String with double quotes escaped
diff --git a/Subtrees/beast/modules/beast_core/diagnostic/beast_Debug.h b/Subtrees/beast/modules/beast_core/diagnostic/beast_Debug.h
index c6013d46c5..e80418e042 100644
--- a/Subtrees/beast/modules/beast_core/diagnostic/beast_Debug.h
+++ b/Subtrees/beast/modules/beast_core/diagnostic/beast_Debug.h
@@ -31,11 +31,16 @@ namespace Debug
*/
extern void breakPoint ();
-// VFALCO NOTE IS THIS REALLY THE RIGHT PLACE FOR THESE??
-//
-// Return only the filename portion of sourceFileName
-// This hides the programmer's directory structure from end-users.
-const String getFileNameFromPath (const char* sourceFileName);
+/** Given a file and line number this formats a suitable string.
+ Usually you will pass __FILE__ and __LINE__ here.
+*/
+String getSourceLocation (char const* fileName, int lineNumber,
+ int numberOfParents = 0);
+
+/** Retrieve the file name from a full path.
+ The nubmer of parents can be chosen
+*/
+String getFileNameFromPath (const char* sourceFileName, int numberOfParents = 0);
// Convert a String that may contain double quotes and newlines
// into a String with double quotes escaped as \" and each
diff --git a/Subtrees/beast/modules/beast_core/diagnostic/beast_Throw.h b/Subtrees/beast/modules/beast_core/diagnostic/beast_Throw.h
index 58b6e8ae70..314c5b1047 100644
--- a/Subtrees/beast/modules/beast_core/diagnostic/beast_Throw.h
+++ b/Subtrees/beast/modules/beast_core/diagnostic/beast_Throw.h
@@ -25,6 +25,11 @@
This provides an opportunity to utilize the debugger before
the stack is unwound.
*/
+namespace Debug
+{
+extern void breakPoint ();
+};
+
template
inline void Throw (Exception const& e, char const* = "", int = 0)
{
diff --git a/Subtrees/beast/modules/beast_core/thread/MutexTraits.h b/Subtrees/beast/modules/beast_core/thread/MutexTraits.h
new file mode 100644
index 0000000000..9de13e042a
--- /dev/null
+++ b/Subtrees/beast/modules/beast_core/thread/MutexTraits.h
@@ -0,0 +1,75 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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_CORE_THREAD_MUTEXTRAITS_H_INCLUDED
+#define BEAST_CORE_THREAD_MUTEXTRAITS_H_INCLUDED
+
+/** Adapt a Mutex type to meet the boost::Mutex concept requirements.
+ The default implementation assumes adherance to the boost::Mutex concepts,
+ with one important exception. We make the member functions const, for
+ convenience.
+*/
+template
+struct MutexTraits
+{
+ // BasicLockable
+ // http://www.boost.org/doc/libs/1_54_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_concepts.basic_lockable
+ //
+ static inline void lock (Mutex const& mutex) noexcept
+ {
+ (const_cast (mutex)).lock ();
+ }
+
+ static inline void unlock (Mutex const& mutex) noexcept
+ {
+ (const_cast (mutex)).unlock ();
+ }
+
+ // Lockable
+ // http://www.boost.org/doc/libs/1_54_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_concepts.basic_lockable
+ //
+ static inline bool try_lock (Mutex const& mutex) noexcept
+ {
+ return (const_cast (mutex)).try_lock ();
+ }
+};
+
+//------------------------------------------------------------------------------
+
+/** MutexTraits Specialization for a beast CriticalSection. */
+template <>
+struct MutexTraits
+{
+ static inline void lock (CriticalSection const& mutex) noexcept
+ {
+ mutex.lock ();
+ }
+
+ static inline void unlock (CriticalSection const& mutex) noexcept
+ {
+ mutex.unlock ();
+ }
+
+ static inline bool try_lock (CriticalSection const& mutex) noexcept
+ {
+ return mutex.try_lock ();
+ }
+};
+
+#endif
diff --git a/Subtrees/beast/modules/beast_core/thread/TrackedMutex.h b/Subtrees/beast/modules/beast_core/thread/TrackedMutex.h
new file mode 100644
index 0000000000..e41dc0b1d4
--- /dev/null
+++ b/Subtrees/beast/modules/beast_core/thread/TrackedMutex.h
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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_CORE_THREAD_TRACKEDMUTEX_H_INCLUDED
+#define BEAST_CORE_THREAD_TRACKEDMUTEX_H_INCLUDED
+
+#include "detail/TrackedMutex.h"
+#include "detail/ScopedLock.h"
+
+#include "impl/TrackedMutex.h"
+#include "impl/TrackedMutexType.h"
+#include "impl/UntrackedMutexType.h"
+
+#endif
diff --git a/Subtrees/beast/modules/beast_core/thread/detail/ScopedLock.h b/Subtrees/beast/modules/beast_core/thread/detail/ScopedLock.h
new file mode 100644
index 0000000000..97045032d0
--- /dev/null
+++ b/Subtrees/beast/modules/beast_core/thread/detail/ScopedLock.h
@@ -0,0 +1,251 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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_CORE_THREAD_DETAIL_SCOPEDLOCK_H_INCLUDED
+#define BEAST_CORE_THREAD_DETAIL_SCOPEDLOCK_H_INCLUDED
+
+#include "../MutexTraits.h"
+
+namespace detail
+{
+
+template
+class TrackedScopedLock : public Uncopyable
+{
+public:
+ inline explicit TrackedScopedLock (Mutex const& mutex,
+ char const* fileName, int lineNumber) noexcept
+ : m_mutex (mutex)
+ , m_lock_count (0)
+ {
+ lock (fileName, lineNumber);
+ }
+
+ inline ~TrackedScopedLock () noexcept
+ {
+ if (m_lock_count > 0)
+ unlock ();
+ }
+
+ inline void lock (char const* fileName, int lineNumber) noexcept
+ {
+ ++m_lock_count;
+ m_mutex.lock (fileName, lineNumber);
+ }
+
+ inline void unlock () noexcept
+ {
+ m_mutex.unlock ();
+ --m_lock_count;
+ }
+
+private:
+ Mutex const& m_mutex;
+ int m_lock_count;
+};
+
+//--------------------------------------------------------------------------
+
+template
+class TrackedScopedTryLock : public Uncopyable
+{
+public:
+ inline explicit TrackedScopedTryLock (Mutex const& mutex,
+ char const* fileName, int lineNumber) noexcept
+ : m_mutex (mutex)
+ , m_lock_count (0)
+ {
+ try_lock (fileName, lineNumber);
+ }
+
+ inline ~TrackedScopedTryLock () noexcept
+ {
+ if (m_lock_count > 0)
+ unlock ();
+ }
+
+ inline bool owns_lock () const noexcept
+ {
+ return m_lock_count > 0;
+ }
+
+ inline bool try_lock (char const* fileName, int lineNumber) noexcept
+ {
+ bool const success = m_mutex.try_lock (fileName, lineNumber);
+ if (success)
+ ++m_lock_count;
+ return success;
+ }
+
+ inline void unlock () noexcept
+ {
+ m_mutex.unlock ();
+ --m_lock_count;
+ }
+
+private:
+ Mutex const& m_mutex;
+ int m_lock_count;
+};
+
+//--------------------------------------------------------------------------
+
+template
+class TrackedScopedUnlock : public Uncopyable
+{
+public:
+ inline explicit TrackedScopedUnlock (Mutex const& mutex,
+ char const* fileName, int lineNumber) noexcept
+ : m_mutex (mutex)
+ , m_fileName (fileName)
+ , m_lineNumber (lineNumber)
+ {
+ m_mutex.unlock ();
+ }
+
+ inline ~TrackedScopedUnlock () noexcept
+ {
+ m_mutex.lock (m_fileName, m_lineNumber);
+ }
+
+private:
+ Mutex const& m_mutex;
+ char const* const m_fileName;
+ int const m_lineNumber;
+};
+
+//--------------------------------------------------------------------------
+
+template
+class UntrackedScopedLock : public Uncopyable
+{
+public:
+ inline explicit UntrackedScopedLock (Mutex const& mutex,
+ char const*, int) noexcept
+ : m_mutex (mutex)
+ , m_lock_count (0)
+ {
+ lock ();
+ }
+
+ inline ~UntrackedScopedLock () noexcept
+ {
+ if (m_lock_count > 0)
+ unlock ();
+ }
+
+ inline void lock () noexcept
+ {
+ ++m_lock_count;
+ m_mutex.lock ();
+ }
+
+ inline void lock (char const*, int) noexcept
+ {
+ lock ();
+ }
+
+ inline void unlock () noexcept
+ {
+ m_mutex.unlock ();
+ --m_lock_count;
+ }
+
+private:
+ Mutex const& m_mutex;
+ int m_lock_count;
+};
+
+//--------------------------------------------------------------------------
+
+template
+class UntrackedScopedTryLock : public Uncopyable
+{
+public:
+ inline explicit UntrackedScopedTryLock (Mutex const& mutex,
+ char const*, int) noexcept
+ : m_mutex (mutex)
+ {
+ try_lock ();
+ }
+
+ inline ~UntrackedScopedTryLock () noexcept
+ {
+ if (m_lock_count > 0)
+ unlock ();
+ }
+
+ inline bool owns_lock () const noexcept
+ {
+ return m_lock_count > 0;
+ }
+
+ inline bool try_lock () noexcept
+ {
+ bool const success = m_mutex.try_lock ();
+ if (success)
+ ++m_lock_count;
+ return success;
+ }
+
+ inline bool try_lock (char const*, int) noexcept
+ {
+ return try_lock ();
+ }
+
+ inline void unlock () noexcept
+ {
+ m_mutex.unlock ();
+ --m_lock_count;
+ }
+
+private:
+ Mutex const& m_mutex;
+ int m_lock_count;
+};
+
+//--------------------------------------------------------------------------
+
+template
+class UntrackedScopedUnlock : public Uncopyable
+{
+public:
+ UntrackedScopedUnlock (Mutex const& mutex,
+ char const*, int) noexcept
+ : m_mutex (mutex)
+ , m_owns_lock (true)
+ {
+ MutexTraits ::unlock (m_mutex);
+ m_owns_lock = false;
+ }
+
+ ~UntrackedScopedUnlock () noexcept
+ {
+ MutexTraits ::lock (m_mutex);
+ m_owns_lock = true;
+ }
+
+private:
+ Mutex const& m_mutex;
+ bool m_owns_lock;
+};
+
+} // namespace detail
+
+#endif
diff --git a/Subtrees/beast/modules/beast_core/thread/detail/TrackedMutex.h b/Subtrees/beast/modules/beast_core/thread/detail/TrackedMutex.h
new file mode 100644
index 0000000000..e291749776
--- /dev/null
+++ b/Subtrees/beast/modules/beast_core/thread/detail/TrackedMutex.h
@@ -0,0 +1,100 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ 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_CORE_THREAD_DETAIL_TRACKEDMUTEX_H_INCLUDED
+#define BEAST_CORE_THREAD_DETAIL_TRACKEDMUTEX_H_INCLUDED
+
+#include "../../containers/beast_List.h"
+#include "../../memory/beast_Atomic.h"
+#include "../../threads/beast_ThreadLocalValue.h"
+
+class TrackedMutex;
+
+namespace detail
+{
+
+struct TrackedMutexBasics
+{
+ struct PerThreadData;
+
+ typedef List ThreadLockList;
+ typedef List GlobalThreadList;
+
+ // Retrieve an atomic counter unique to class Object
+ template
+ static Atomic & getCounter () noexcept
+ {
+ static Atomic counter;
+ return counter;
+ }
+
+ template
+ inline static String createName (String name,
+ char const* fileName, int lineNumber)
+ {
+ return createName (name, fileName, lineNumber,
+ ++getCounter