diff --git a/Builds/VisualStudio2012/beast.vcxproj b/Builds/VisualStudio2012/beast.vcxproj
index 422e763b14..1fbc577a85 100644
--- a/Builds/VisualStudio2012/beast.vcxproj
+++ b/Builds/VisualStudio2012/beast.vcxproj
@@ -210,7 +210,7 @@
-
+
@@ -285,7 +285,6 @@
-
diff --git a/Builds/VisualStudio2012/beast.vcxproj.filters b/Builds/VisualStudio2012/beast.vcxproj.filters
index 48c0f1d7c8..7e8967d03e 100644
--- a/Builds/VisualStudio2012/beast.vcxproj.filters
+++ b/Builds/VisualStudio2012/beast.vcxproj.filters
@@ -557,9 +557,6 @@
beast_core\memory
-
- beast_core\memory
-
beast_core\maths
@@ -728,9 +725,6 @@
beast_core\thread
-
- beast_core\thread
-
beast_core\thread
@@ -1028,6 +1022,9 @@
beast_asio\basics
+
+ beast_core\memory
+
diff --git a/TODO.txt b/TODO.txt
index bf1437e8e0..777b5dcc9f 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -2,9 +2,12 @@
BEAST TODO
--------------------------------------------------------------------------------
-- Use new file naming convention
+- Remove ReadWriteMutex and replace it with a CriticalSection
+ since the implementation is broken.
-- Rename ReadWriteMutex to SharedMutex
+- Rewrite SharedData to work with a CriticalSection
+
+- Use new file naming convention
- Use SemanticVersion for beast version numbers to replace BEAST_VERSION
diff --git a/modules/beast_core/beast_core.h b/modules/beast_core/beast_core.h
index 1e0e7a0527..cb65de75c4 100644
--- a/modules/beast_core/beast_core.h
+++ b/modules/beast_core/beast_core.h
@@ -363,7 +363,7 @@ extern BEAST_API void BEAST_CALLTYPE logAssertion (char const* file, int line) n
#include "memory/beast_ByteOrder.h"
#include "memory/beast_Memory.h"
#include "memory/beast_OptionalScopedPointer.h"
-#include "memory/beast_SharedSingleton.h"
+#include "memory/SharedSingleton.h"
#include "memory/beast_WeakReference.h"
#include "memory/beast_RecycledObjectPool.h"
#include "misc/beast_Main.h"
@@ -421,7 +421,6 @@ extern BEAST_API void BEAST_CALLTYPE logAssertion (char const* file, int line) n
#include "thread/beast_InterruptibleThread.h"
#include "thread/beast_ThreadGroup.h"
#include "thread/beast_CallQueue.h"
-#include "thread/beast_GlobalThreadGroup.h"
#include "thread/beast_Listeners.h"
#include "thread/beast_ManualCallQueue.h"
#include "thread/beast_ParallelFor.h"
diff --git a/modules/beast_core/files/beast_File.cpp b/modules/beast_core/files/beast_File.cpp
index 319f4ab965..9717dca5da 100644
--- a/modules/beast_core/files/beast_File.cpp
+++ b/modules/beast_core/files/beast_File.cpp
@@ -24,20 +24,15 @@
// We need to make a shared singleton or else there are
// issues with the leak detector and order of detruction.
//
-class NonexistentHolder : public SharedSingleton
+class NonexistentHolder
{
public:
- NonexistentHolder ()
- : SharedSingleton (SingletonLifetime::persistAfterCreation)
+ static NonexistentHolder* getInstance()
{
+ return SharedSingleton ::getInstance();
}
- static NonexistentHolder* createInstance ()
- {
- return new NonexistentHolder;
- }
-
- File const file;
+ File file;
};
File const& File::nonexistent ()
diff --git a/modules/beast_core/memory/SharedPtr.h b/modules/beast_core/memory/SharedPtr.h
index e619a64805..989950d24a 100644
--- a/modules/beast_core/memory/SharedPtr.h
+++ b/modules/beast_core/memory/SharedPtr.h
@@ -74,7 +74,7 @@ public:
Requirement:
U* must be convertible to T*
*/
- /// @{
+ /** @{ */
SharedPtr (T* t) noexcept
: m_p (acquire (t))
{
@@ -85,14 +85,14 @@ public:
: m_p (acquire (u))
{
}
- /// @}
+ /** @} */
/** Construct a container holding an object from another container.
This will increment the object's reference-count (if it is non-null).
Requirement:
U* must be convertible to T*
*/
- /// @{
+ /** @{ */
#if BEAST_SHAREDPTR_PROVIDE_COMPILER_WORKAROUNDS
SharedPtr (SharedPtr const& sp) noexcept
: m_p (acquire (sp.get ()))
@@ -105,7 +105,7 @@ public:
: m_p (acquire (sp.get ()))
{
}
- /// @}
+ /** @} */
/** Assign a different object to the container.
The previous object beind held, if any, loses a reference count and
@@ -113,7 +113,7 @@ public:
Requirement:
U* must be convertible to T*
*/
- /// @{
+ /** @{ */
#if BEAST_SHAREDPTR_PROVIDE_COMPILER_WORKAROUNDS
SharedPtr& operator= (T* t)
{
@@ -126,10 +126,10 @@ public:
{
return assign (u);
}
- /// @}
+ /** @} */
/** Assign an object from another container to this one. */
- /// @{
+ /** @{ */
SharedPtr& operator= (SharedPtr const& sp)
{
return assign (sp.get ());
@@ -141,7 +141,7 @@ public:
{
return assign (sp.get ());
}
- /// @}
+ /** @} */
#if BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS
/** Construct a container with an object transferred from another container.
@@ -149,7 +149,7 @@ public:
Requires:
U* must be convertible to T*
*/
- /// @{
+ /** @{ */
#if BEAST_SHAREDPTR_PROVIDE_COMPILER_WORKAROUNDS
SharedPtr (SharedPtr && sp) noexcept
: m_p (sp.swap (nullptr))
@@ -162,14 +162,14 @@ public:
: m_p (sp.swap (nullptr))
{
}
- /// @}
+ /** @} */
/** Transfer ownership of another object to this container.
The originating container loses its reference to the object.
Requires:
U* must be convertible to T*
*/
- /// @{
+ /** @{ */
#if BEAST_SHAREDPTR_PROVIDE_COMPILER_WORKAROUNDS
SharedPtr& operator= (SharedPtr && sp)
{
@@ -182,7 +182,7 @@ public:
{
return assign (sp.swap (nullptr));
}
- /// @}
+ /** @} */
#endif
/** Destroy the container and release the held reference, if any.
@@ -262,8 +262,8 @@ private:
//------------------------------------------------------------------------------
-/// SharedPtr comparisons.
-/// @{
+/** SharedPtr comparisons. */
+/** @{ */
template
bool operator== (SharedPtr const& lhs, U* const rhs) noexcept
{
@@ -277,28 +277,28 @@ bool operator== (SharedPtr const& lhs, SharedPtr const& rhs) noexcept
}
template
-bool operator== (T const* lhs, SharedPtr const& rhs) noexcept
+bool operator== (T const* lhs, SharedPtr const& rhs) noexcept
{
return lhs == rhs.get();
}
template
-bool operator!= (SharedPtr const& lhs, T const* rhs) noexcept
+bool operator!= (SharedPtr const& lhs, U const* rhs) noexcept
{
return lhs.get() != rhs;
}
template
-bool operator!= (SharedPtr const& lhs, SharedPtr const& rhs) noexcept
+bool operator!= (SharedPtr const& lhs, SharedPtr const& rhs) noexcept
{
return lhs.get() != rhs.get();
}
template
-bool operator!= (T const* lhs, SharedPtr const& rhs) noexcept
+bool operator!= (T const* lhs, SharedPtr const& rhs) noexcept
{
return lhs != rhs.get();
}
-/// @}
+/** @} */
#endif
diff --git a/modules/beast_core/memory/beast_SharedSingleton.h b/modules/beast_core/memory/SharedSingleton.h
similarity index 57%
rename from modules/beast_core/memory/beast_SharedSingleton.h
rename to modules/beast_core/memory/SharedSingleton.h
index 8e8b146113..a14a146ef5 100644
--- a/modules/beast_core/memory/beast_SharedSingleton.h
+++ b/modules/beast_core/memory/SharedSingleton.h
@@ -17,8 +17,8 @@
*/
//==============================================================================
-#ifndef BEAST_REFERENCECOUNTEDSINGLETON_H_INCLUDED
-#define BEAST_REFERENCECOUNTEDSINGLETON_H_INCLUDED
+#ifndef BEAST_SHAREDSINGLETON_H_INCLUDED
+#define BEAST_SHAREDSINGLETON_H_INCLUDED
/** Thread-safe singleton which comes into existence on first use. Use this
instead of creating objects with static storage duration. These singletons
@@ -52,11 +52,6 @@ public:
*/
createOnDemand,
- /** Like createOnDemand, but after the Singleton is destroyed an
- exception will be thrown if an attempt is made to create it again.
- */
- createOnDemandOnce,
-
/** The singleton is created on first use and persists until program exit.
*/
persistAfterCreation,
@@ -71,131 +66,128 @@ public:
//------------------------------------------------------------------------------
+/** Wraps object to produce a reference counted singleton. */
template
class SharedSingleton
- : public SingletonLifetime
- , private PerformedAtExit
+ : public Object
+ , private SharedObject
{
-protected:
- typedef SpinLock LockType;
-
- /** Create the singleton.
-
- @param lifetime The lifetime management option.
- */
- explicit SharedSingleton (Lifetime const lifetime)
- : m_lifetime (lifetime)
- {
- bassert (s_instance == nullptr);
-
- if (m_lifetime == persistAfterCreation ||
- m_lifetime == neverDestroyed)
- {
- incReferenceCount ();
- }
- }
-
- virtual ~SharedSingleton ()
- {
- bassert (s_instance == nullptr);
- }
-
public:
- typedef SharedPtr