diff --git a/src/beast/Builds/VisualStudio2012/beast.vcxproj b/src/beast/Builds/VisualStudio2012/beast.vcxproj
index 31214704c..b6934c6da 100644
--- a/src/beast/Builds/VisualStudio2012/beast.vcxproj
+++ b/src/beast/Builds/VisualStudio2012/beast.vcxproj
@@ -69,12 +69,17 @@
+
+
+
+
+
@@ -155,14 +160,10 @@
-
-
-
-
@@ -208,7 +209,6 @@
-
diff --git a/src/beast/Builds/VisualStudio2012/beast.vcxproj.filters b/src/beast/Builds/VisualStudio2012/beast.vcxproj.filters
index bfbc9c093..aad5b086e 100644
--- a/src/beast/Builds/VisualStudio2012/beast.vcxproj.filters
+++ b/src/beast/Builds/VisualStudio2012/beast.vcxproj.filters
@@ -165,9 +165,6 @@
{bf498396-2e1f-4903-be68-3053ba439af5}
-
- {08ec13ba-4058-4ad7-afbb-cbb1c6e2fc4a}
-
{92d1bb42-289a-4444-85c7-cb87540f2fff}
@@ -296,9 +293,6 @@
beast_core\maths
-
- beast_core\memory
-
beast_core\memory
@@ -549,9 +543,6 @@
beast_core\containers
-
- beast_core\containers
-
beast_core\threads
@@ -822,15 +813,6 @@
beast_core\containers
-
- beast_core\containers
-
-
- beast_core\containers\detail
-
-
- beast_core\containers\detail
-
beast_core\text
@@ -1104,6 +1086,21 @@
beast_asio\basics
+
+ beast
+
+
+ beast
+
+
+ beast\intrusive
+
+
+ beast\intrusive
+
+
+ beast\mpl
+
diff --git a/src/beast/modules/beast_core/memory/Atomic.h b/src/beast/beast/Atomic.h
similarity index 99%
rename from src/beast/modules/beast_core/memory/Atomic.h
rename to src/beast/beast/Atomic.h
index 7650da579..fa498aadc 100644
--- a/src/beast/modules/beast_core/memory/Atomic.h
+++ b/src/beast/beast/Atomic.h
@@ -24,6 +24,7 @@
#ifndef BEAST_ATOMIC_H_INCLUDED
#define BEAST_ATOMIC_H_INCLUDED
+namespace beast {
//==============================================================================
/**
@@ -385,5 +386,6 @@ inline void memoryBarrier() noexcept
#pragma warning (pop)
#endif
-#endif
+}
+#endif
diff --git a/src/beast/modules/beast_core/containers/detail/removecv.h b/src/beast/beast/Intrusive.h
similarity index 55%
rename from src/beast/modules/beast_core/containers/detail/removecv.h
rename to src/beast/beast/Intrusive.h
index 19b3d3bc4..0deb0e846 100644
--- a/src/beast/modules/beast_core/containers/detail/removecv.h
+++ b/src/beast/beast/Intrusive.h
@@ -17,57 +17,11 @@
*/
//==============================================================================
-#ifndef BEAST_CORE_CONTAINERS_DETAIL_REMOVECV_H_INCLUDED
-#define BEAST_CORE_CONTAINERS_DETAIL_REMOVECV_H_INCLUDED
+#ifndef BEAST_INTRUSIVE_H_INCLUDED
+#define BEAST_INTRUSIVE_H_INCLUDED
-namespace detail
-{
-
-// Strip all cv qualifiers from T
-template
-struct removecv
-{
- typedef T type;
-};
-
-template
-struct removecv
-{
- typedef typename removecv ::type type;
-};
-
-template
-struct removecv
-{
- typedef typename removecv ::type type;
-};
-
-template
-struct removecv
-{
- typedef typename removecv ::type type;
-};
-
-template
-struct removecv
-{
- typedef typename removecv ::type type;
-};
-
-template
-struct removecv
-{
- typedef typename removecv ::type type;
-};
-
-#if BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS
-template
-struct removecv
-{
- typedef typename removecv ::type type;
-};
-#endif
-
-}
+#include "intrusive/ForwardList.h"
+#include "intrusive/List.h"
+#include "intrusive/LockFreeStack.h"
#endif
diff --git a/src/beast/beast/MPL.h b/src/beast/beast/MPL.h
index 59399ddbd..3be24c673 100644
--- a/src/beast/beast/MPL.h
+++ b/src/beast/beast/MPL.h
@@ -21,6 +21,7 @@
#define BEAST_MPL_H_INCLUDED
#include "mpl/AddConst.h"
+#include "mpl/CopyConst.h"
#include "mpl/IfCond.h"
#include "mpl/IsCallPossible.h"
#include "mpl/PointerToOther.h"
diff --git a/src/beast/beast/intrusive/ForwardList.h b/src/beast/beast/intrusive/ForwardList.h
index 8ace8541c..6c73f6696 100644
--- a/src/beast/beast/intrusive/ForwardList.h
+++ b/src/beast/beast/intrusive/ForwardList.h
@@ -21,7 +21,6 @@
#define BEAST_INTRUSIVE_FORWARDLIST_H_INCLUDED
#include
-
#include "PointerTraits.h"
#include "../MPL.h"
diff --git a/src/beast/modules/beast_core/containers/List.h b/src/beast/beast/intrusive/List.h
similarity index 97%
rename from src/beast/modules/beast_core/containers/List.h
rename to src/beast/beast/intrusive/List.h
index 2a125ff7d..b4d4fdbdc 100644
--- a/src/beast/modules/beast_core/containers/List.h
+++ b/src/beast/beast/intrusive/List.h
@@ -17,8 +17,14 @@
*/
//==============================================================================
-#ifndef BEAST_CORE_CONTAINERS_LIST_H_INCLUDED
-#define BEAST_CORE_CONTAINERS_LIST_H_INCLUDED
+#ifndef BEAST_INTRUSIVE_LIST_H_INCLUDED
+#define BEAST_INTRUSIVE_LIST_H_INCLUDED
+
+#include
+#include "../mpl/CopyConst.h"
+#include "../Uncopyable.h"
+
+namespace beast {
/** Intrusive Containers
@@ -225,8 +231,7 @@ class ListIterator : public std::iterator <
std::bidirectional_iterator_tag, std::size_t>
{
public:
- typedef typename copyconst ::type
-
+ typedef typename mpl::CopyConst::type
value_type;
typedef value_type* pointer;
typedef value_type& reference;
@@ -243,14 +248,6 @@ public:
{
}
-#if 0
- template
- ListIterator& operator= (ListIterator const& other) noexcept
- {
- m_node = other.m_node;
- return *this;
- }
-#endif
template
bool operator== (ListIterator const& other) const noexcept
{
@@ -307,14 +304,11 @@ private:
void increment () noexcept
{
- bassert (m_node->m_next);
m_node = m_node->m_next;
}
void decrement () noexcept
{
- bassert (m_node->m_prev &&
- m_node->m_prev->m_prev != nullptr);
m_node = m_node->m_prev;
}
@@ -323,8 +317,7 @@ private:
}
-/**
- Intrusive doubly linked list.
+/** Intrusive doubly linked list.
This intrusive List is a container similar in operation to std::list in the
Standard Template Library (STL). Like all @ref intrusive containers, List
@@ -583,7 +576,6 @@ public:
@param pos The location to insert after.
@param other The list to insert.
*/
-
void insert (iterator pos, List& other) noexcept
{
if (!other.empty ())
@@ -717,4 +709,6 @@ private:
Node m_tail;
};
+}
+
#endif
diff --git a/src/beast/modules/beast_core/containers/LockFreeStack.h b/src/beast/beast/intrusive/LockFreeStack.h
similarity index 65%
rename from src/beast/modules/beast_core/containers/LockFreeStack.h
rename to src/beast/beast/intrusive/LockFreeStack.h
index 734a7d2dd..c68420480 100644
--- a/src/beast/modules/beast_core/containers/LockFreeStack.h
+++ b/src/beast/beast/intrusive/LockFreeStack.h
@@ -17,12 +17,17 @@
*/
//==============================================================================
-#ifndef BEAST_LOCKFREESTACK_H_INCLUDED
-#define BEAST_LOCKFREESTACK_H_INCLUDED
+#ifndef BEAST_INTRUSIVE_LOCKFREESTACK_H_INCLUDED
+#define BEAST_INTRUSIVE_LOCKFREESTACK_H_INCLUDED
-struct LockFreeStackDefaultTag;
+#include
+#include "../mpl/IfCond.h"
+#include "../Atomic.h"
+#include "../Uncopyable.h"
-/*============================================================================*/
+namespace beast {
+
+//------------------------------------------------------------------------------
template
class LockFreeStackIterator
@@ -74,7 +79,7 @@ public:
LockFreeStackIterator& operator++ ()
{
- m_node = m_node->m_next;
+ m_node = m_node->m_next.get();
return static_cast (*this);
}
@@ -85,16 +90,9 @@ public:
return result;
}
- template
- bool operator== (LockFreeStackIterator const& other)
+ NodePtr node() const
{
- return m_node == other.m_node;
- }
-
- template
- bool operator!= (LockFreeStackIterator const& other)
- {
- return m_node != other.m_node;
+ return m_node;
}
reference operator* () const
@@ -111,20 +109,35 @@ private:
NodePtr m_node;
};
-/**
- Multiple Producer, Multiple Consumer (MPMC) intrusive stack.
+//------------------------------------------------------------------------------
- This stack is implemented using the same intrusive interface as List. All
- operations are lock-free.
+template
+bool operator== (LockFreeStackIterator const& lhs,
+ LockFreeStackIterator const& rhs)
+{
+ return lhs.node() == rhs.node();
+}
- The caller is responsible for preventing the "ABA" problem
- (http://en.wikipedia.org/wiki/ABA_problem)
+template
+bool operator!= (LockFreeStackIterator const& lhs,
+ LockFreeStackIterator const& rhs)
+{
+ return lhs.node() != rhs.node();
+}
- @param Tag A type name used to distinguish lists and nodes, for
- putting objects in multiple lists. If this parameter is
- omitted, the default tag is used.
+//------------------------------------------------------------------------------
- @ingroup beast_core intrusive
+/** Multiple Producer, Multiple Consumer (MPMC) intrusive stack.
+
+ This stack is implemented using the same intrusive interface as List.
+ All mutations are lock-free.
+
+ The caller is responsible for preventing the "ABA" problem:
+ http://en.wikipedia.org/wiki/ABA_problem
+
+ @param Tag A type name used to distinguish lists and nodes, for
+ putting objects in multiple lists. If this parameter is
+ omitted, the default tag is used.
*/
template
class LockFreeStack : public Uncopyable
@@ -147,8 +160,7 @@ public:
template
friend class LockFreeStackIterator;
- // VFALCO TODO Use regular Atomic<>
- AtomicPointer m_next;
+ Atomic m_next;
};
public:
@@ -164,36 +176,15 @@ public:
typedef LockFreeStackIterator <
LockFreeStack , true> const_iterator;
- LockFreeStack () : m_head (nullptr)
+ LockFreeStack ()
+ : m_end (nullptr)
+ , m_head (&m_end)
{
}
-#if 0
- /** Create a LockFreeStack from another stack.
-
- The contents of the other stack are atomically acquired.
- The other stack is cleared.
-
- @param other The other stack to acquire.
- */
- explicit LockFreeStack (LockFreeStack& other)
- {
- Node* head;
-
- do
- {
- head = other.m_head.get ();
- }
- while (!other.m_head.compareAndSet (0, head));
-
- m_head = head;
- }
-#endif
-
/** Return the number of elements in the stack.
-
Thread safety:
- Safe to call from any thread but the value may be inaccurate.
+ Safe to call from any thread.
*/
size_type size () const
{
@@ -201,77 +192,63 @@ public:
}
/** Push a node onto the stack.
-
- The caller is responsible for preventing the ABA problem. This operation
- is lock-free.
+ The caller is responsible for preventing the ABA problem.
+ This operation is lock-free.
+ Thread safety:
+ Safe to call from any thread.
@param node The node to push.
- @return True if the stack was previously empty. If multiple threads
- are attempting to push, only one will receive true.
+ @return `true` if the stack was previously empty. If multiple threads
+ are attempting to push, only one will receive `true`.
*/
bool push_front (Node* node)
{
bool first;
Node* head;
-
do
{
head = m_head.get ();
- first = head == 0;
+ first = head == &m_end;
node->m_next = head;
}
- while (!m_head.compareAndSet (node, head));
-
+ while (!m_head.compareAndSetBool (node, head));
++m_size;
-
return first;
}
/** Pop an element off the stack.
+ The caller is responsible for preventing the ABA problem.
+ This operation is lock-free.
+ Thread safety:
+ Safe to call from any thread.
- The caller is responsible for preventing the ABA problem. This operation
- is lock-free.
-
- @return The element that was popped, or nullptr if the stack was empty.
+ @return The element that was popped, or `nullptr` if the stack
+ was empty.
*/
Element* pop_front ()
{
Node* node;
Node* head;
-
do
{
node = m_head.get ();
-
- if (node == 0)
- break;
-
+ if (node == &m_end)
+ return nullptr;
head = node->m_next.get ();
}
- while (!m_head.compareAndSet (head, node));
-
+ while (!m_head.compareAndSetBool (head, node));
--m_size;
-
- return node ? static_cast (node) : nullptr;
+ return static_cast (node);
}
- /** Swap the contents of this stack with another stack.
-
- This call is not thread safe or atomic. The caller is responsible for
- synchronizing access.
-
- @param other The other stack to swap contents with.
+ /** Return a forward iterator to the beginning or end of the stack.
+ Undefined behavior results if push_front or pop_front is called
+ while an iteration is in progress.
+ Thread safety:
+ Caller is responsible for synchronization.
*/
- void swap (LockFreeStack& other)
- {
- Node* temp = other.m_head.get ();
- other.m_head.set (m_head.get ());
- m_head.set (temp);
-
- std::swap (m_size.value, other.m_size.value);
- }
-
+ /** @{ */
iterator begin ()
{
return iterator (m_head.get ());
@@ -279,7 +256,7 @@ public:
iterator end ()
{
- return iterator ();
+ return iterator (&m_end);
}
const_iterator begin () const
@@ -289,7 +266,7 @@ public:
const_iterator end () const
{
- return const_iterator ();
+ return const_iterator (&m_end);
}
const_iterator cbegin () const
@@ -299,12 +276,16 @@ public:
const_iterator cend () const
{
- return const_iterator ();
+ return const_iterator (&m_end);
}
-
+ /** @} */
+
private:
+ Node m_end;
Atomic m_size;
- AtomicPointer m_head;
+ Atomic m_head;
};
+}
+
#endif
diff --git a/src/beast/beast/mpl/AddConst.h b/src/beast/beast/mpl/AddConst.h
index 4b25ecd0b..3ab16e6b7 100644
--- a/src/beast/beast/mpl/AddConst.h
+++ b/src/beast/beast/mpl/AddConst.h
@@ -20,16 +20,18 @@
#ifndef BEAST_MPL_ADDCONST_H_INCLUDED
#define BEAST_MPL_ADDCONST_H_INCLUDED
+#include "RemoveConst.h"
+
// Ideas based on boost
namespace beast {
namespace mpl {
-/// Add the `const` qualifier to a type.
+/** Add the `const` qualifier to a type. */
template
struct AddConst
{
- typedef T const type;
+ typedef typename RemoveConst::type const type;
};
}
diff --git a/src/beast/modules/beast_core/containers/detail/copyconst.h b/src/beast/beast/mpl/CopyConst.h
similarity index 75%
rename from src/beast/modules/beast_core/containers/detail/copyconst.h
rename to src/beast/beast/mpl/CopyConst.h
index ac8d74d5c..a733ded88 100644
--- a/src/beast/modules/beast_core/containers/detail/copyconst.h
+++ b/src/beast/beast/mpl/CopyConst.h
@@ -17,25 +17,30 @@
*/
//==============================================================================
-#ifndef BEAST_CORE_CONTAINERS_DETAIL_COPYCONST_H_INCLUDED
-#define BEAST_CORE_CONTAINERS_DETAIL_COPYCONST_H_INCLUDED
+#ifndef BEAST_MPL_COPYCONST_H_INCLUDED
+#define BEAST_MPL_COPYCONST_H_INCLUDED
-namespace detail
-{
+#include "RemoveConst.h"
-// Copy const attribute from T to U if present
+namespace beast {
+namespace mpl {
+
+/** Copy `const` attribute from T to U if present. */
+/** @{ */
template
-struct copyconst
+struct CopyConst
{
- typedef typename removecv ::type type;
+ typedef typename RemoveConst::type type;
};
template
-struct copyconst
+struct CopyConst
{
- typedef typename removecv ::type const type;
+ typedef typename RemoveConst::type const type;
};
+/** @} */
+}
}
#endif
diff --git a/src/beast/beast/mpl/IfCond.h b/src/beast/beast/mpl/IfCond.h
index 499dfced7..44aad1613 100644
--- a/src/beast/beast/mpl/IfCond.h
+++ b/src/beast/beast/mpl/IfCond.h
@@ -25,8 +25,8 @@ namespace mpl {
// Ideas based on boost
-/// Select between T1 or T2 depending on Condition.
-/// @{
+/** Select between T1 or T2 depending on Condition. */
+/** @{ */
template
struct IfCond
{
@@ -38,7 +38,7 @@ struct IfCond
{
typedef T2 type;
};
-/// @}
+/** @} */
}
}
diff --git a/src/beast/beast/mpl/PointerToOther.h b/src/beast/beast/mpl/PointerToOther.h
index 868d46bb0..8a82274f3 100644
--- a/src/beast/beast/mpl/PointerToOther.h
+++ b/src/beast/beast/mpl/PointerToOther.h
@@ -30,7 +30,7 @@ namespace mpl {
parameters. More specializations can be added for containers with
more than three template parameters.
*/
-/// @{
+/** @{ */
template
struct PointerToOther;
@@ -60,7 +60,7 @@ struct PointerToOther
{
typedef U* type;
};
-/// @}
+/** @} */
}
}
diff --git a/src/beast/beast/mpl/RemoveConst.h b/src/beast/beast/mpl/RemoveConst.h
index 4f555f26a..86f58b9f3 100644
--- a/src/beast/beast/mpl/RemoveConst.h
+++ b/src/beast/beast/mpl/RemoveConst.h
@@ -25,8 +25,8 @@
namespace beast {
namespace mpl {
-/// Remove the `const` qualifier from a type.
-/// @{
+/** Remove the `const` qualifier from a type. */
+/** @{ */
template
struct RemoveConst
{
@@ -38,7 +38,7 @@ struct RemoveConst
{
typedef T type;
};
-/// @}
+/** @} */
}
}
diff --git a/src/beast/beast/mpl/RemoveConstVolatile.h b/src/beast/beast/mpl/RemoveConstVolatile.h
index 361f0255a..b320d507b 100644
--- a/src/beast/beast/mpl/RemoveConstVolatile.h
+++ b/src/beast/beast/mpl/RemoveConstVolatile.h
@@ -28,7 +28,7 @@
namespace beast {
namespace mpl {
-/// Remove both the `const` and `volatile` qualifiers from a type.
+/** Remove both the `const` and `volatile` qualifiers from a type. */
template
struct RemoveConstVolatile
{
diff --git a/src/beast/beast/mpl/RemoveReference.h b/src/beast/beast/mpl/RemoveReference.h
index 239addcca..c7b8d6d65 100644
--- a/src/beast/beast/mpl/RemoveReference.h
+++ b/src/beast/beast/mpl/RemoveReference.h
@@ -25,8 +25,8 @@ namespace mpl {
// Ideas based on boost
-/// Remove the reference qualifier from a type.
-/// @{
+/** Remove the reference qualifier from a type. */
+/** @{ */
template
struct RemoveReference
{
@@ -38,7 +38,7 @@ struct RemoveReference
{
typedef T type;
};
-/// @}
+/** @} */
}
}
diff --git a/src/beast/beast/mpl/RemoveVolatile.h b/src/beast/beast/mpl/RemoveVolatile.h
index 26a848724..5057a16bd 100644
--- a/src/beast/beast/mpl/RemoveVolatile.h
+++ b/src/beast/beast/mpl/RemoveVolatile.h
@@ -25,8 +25,8 @@
namespace beast {
namespace mpl {
-/// Remove the `volatile` qualifier from a type.
-/// @{
+/** Remove the `volatile` qualifier from a type. */
+/** @{ */
template
struct RemoveVolatile
{
@@ -38,7 +38,7 @@ struct RemoveVolatile
{
typedef T type;
};
-/// @}
+/** @} */
}
}
diff --git a/src/beast/beast/net/IPEndpoint.h b/src/beast/beast/net/IPEndpoint.h
index 20083c3d7..f37439455 100644
--- a/src/beast/beast/net/IPEndpoint.h
+++ b/src/beast/beast/net/IPEndpoint.h
@@ -120,8 +120,6 @@ public:
template
Proxy& operator= (IntegralType v)
{
- bassert (v >= 0 && v <= 255);
-
(*m_value)=
(*m_value)&(!((0xff)< struct IsIntegral : FalseType { };
diff --git a/src/beast/beast/type_traits/IsSigned.h b/src/beast/beast/type_traits/IsSigned.h
index cc3c499a2..36db7d93d 100644
--- a/src/beast/beast/type_traits/IsSigned.h
+++ b/src/beast/beast/type_traits/IsSigned.h
@@ -22,8 +22,7 @@
#include "IntegralConstant.h"
-namespace beast
-{
+namespace beast {
template struct IsSigned : FalseType { };
diff --git a/src/beast/beast/type_traits/RemoveSigned.h b/src/beast/beast/type_traits/RemoveSigned.h
index a226aced8..cd12e0e14 100644
--- a/src/beast/beast/type_traits/RemoveSigned.h
+++ b/src/beast/beast/type_traits/RemoveSigned.h
@@ -22,8 +22,7 @@
#include "IntegralConstant.h"
-namespace beast
-{
+namespace beast {
/** Returns an equally sized, unsigned type.
Requires:
@@ -33,12 +32,12 @@ template
struct RemoveSigned
{
typedef T type;
-}
+};
-template <> struct RemoveSigned { typedef uint8 type; }
-template <> struct RemoveSigned { typedef uint16 type; }
-template <> struct RemoveSigned { typedef uint32 type; }
-template <> struct RemoveSigned { typedef uint64 type; }
+template <> struct RemoveSigned { typedef uint8 type; };
+template <> struct RemoveSigned { typedef uint16 type; };
+template <> struct RemoveSigned { typedef uint32 type; };
+template <> struct RemoveSigned { typedef uint64 type; };
}
diff --git a/src/beast/modules/beast_core/beast_core.h b/src/beast/modules/beast_core/beast_core.h
index 6d4457250..d403109c5 100644
--- a/src/beast/modules/beast_core/beast_core.h
+++ b/src/beast/modules/beast_core/beast_core.h
@@ -76,21 +76,28 @@
//------------------------------------------------------------------------------
+namespace beast {
+extern BEAST_API bool BEAST_CALLTYPE beast_isRunningUnderDebugger();
+extern BEAST_API void BEAST_CALLTYPE logAssertion (char const* file, int line) noexcept;
+}
+
+// New header-only library modeled more closely according to boost
#include "../../beast/CStdInt.h"
#include "../../beast/StaticAssert.h"
#include "../../beast/Uncopyable.h"
+#include "../../beast/Atomic.h"
+#include "../../beast/Intrusive.h"
+#include "../../beast/Net.h"
+#include "../../beast/TypeTraits.h"
+#include "../../beast/Thread.h"
-namespace beast
-{
+namespace beast {
class InputStream;
class OutputStream;
class FileInputStream;
class FileOutputStream;
-extern BEAST_API bool BEAST_CALLTYPE beast_isRunningUnderDebugger();
-extern BEAST_API void BEAST_CALLTYPE logAssertion (char const* file, int line) noexcept;
-
// Order matters, since headers don't have their own #include lines.
// Add new includes to the bottom.
@@ -98,23 +105,8 @@ extern BEAST_API void BEAST_CALLTYPE logAssertion (char const* file, int line) n
#include "memory/Memory.h"
#include "maths/MathsFunctions.h"
#include "memory/ByteOrder.h"
-#include "memory/Atomic.h"
#include "text/CharacterFunctions.h"
-}
-
-//------------------------------------------------------------------------------
-
-// New header-only library modeled more closely according to boost
-#include "../../beast/intrusive/ForwardList.h"
-#include "../../beast/Net.h"
-#include "../../beast/Thread.h"
-
-//------------------------------------------------------------------------------
-
-namespace beast
-{
-
#if BEAST_MSVC
# pragma warning (push)
# pragma warning (disable: 4514 4996)
@@ -127,16 +119,12 @@ namespace beast
# pragma warning (pop)
#endif
-# include "containers/detail/removecv.h"
-#include "containers/detail/copyconst.h"
#include "diagnostic/Throw.h"
#include "system/Functional.h"
#include "memory/AtomicCounter.h"
#include "memory/AtomicFlag.h"
#include "memory/AtomicPointer.h"
#include "memory/AtomicState.h"
-#include "containers/List.h"
-#include "containers/LockFreeStack.h"
#include "threads/SpinDelay.h"
#include "memory/StaticObject.h"
diff --git a/src/beast/modules/beast_core/containers/DynamicArray.h b/src/beast/modules/beast_core/containers/DynamicArray.h
index 82aeb08cf..fbd54e106 100644
--- a/src/beast/modules/beast_core/containers/DynamicArray.h
+++ b/src/beast/modules/beast_core/containers/DynamicArray.h
@@ -32,7 +32,7 @@ class DynamicArrayIterator
typename V::size_type>
{
public:
- typedef typename copyconst ::type
+ typedef typename mpl::CopyConst ::type
value_type;
typedef value_type* pointer;
@@ -216,7 +216,7 @@ class DynamicArrayReverseIterator
typename V::size_type>
{
public:
- typedef typename copyconst ::type
+ typedef typename mpl::CopyConst::type
value_type;
typedef value_type* pointer;
diff --git a/src/beast/modules/beast_core/containers/HashMap.h b/src/beast/modules/beast_core/containers/HashMap.h
index e1f46f5a0..4d1caa529 100644
--- a/src/beast/modules/beast_core/containers/HashMap.h
+++ b/src/beast/modules/beast_core/containers/HashMap.h
@@ -193,9 +193,9 @@ class HashMapIterator
private:
typedef typename M::Item Item;
typedef typename M::Bucket Bucket;
- typedef detail::ListIterator ::Node>::type> bucket_iterator;
- typedef detail::ListIterator ::Node>::type> item_iterator;
public:
diff --git a/src/beast/modules/beast_core/containers/LockFreeQueue.h b/src/beast/modules/beast_core/containers/LockFreeQueue.h
index 7c3e0e599..b01519ef8 100644
--- a/src/beast/modules/beast_core/containers/LockFreeQueue.h
+++ b/src/beast/modules/beast_core/containers/LockFreeQueue.h
@@ -17,14 +17,8 @@
*/
//==============================================================================
-#ifndef BEAST_LOCKFREEQUEUE_H_INCLUDED
-#define BEAST_LOCKFREEQUEUE_H_INCLUDED
-
-/** Default tag for LockFreeQueue
-
- @ingroup beast_core intrusive
-*/
-struct LockFreeQueueDefaultTag { };
+#ifndef BEAST_INTRUSIVE_LOCKFREEQUEUE_H_INCLUDED
+#define BEAST_INTRUSIVE_LOCKFREEQUEUE_H_INCLUDED
/** Multiple Producer, Single Consumer (MPSC) intrusive FIFO.
@@ -46,7 +40,7 @@ struct LockFreeQueueDefaultTag { };
@ingroup beast_core intrusive
*/
-template
+template
class LockFreeQueue
{
public:
diff --git a/src/beast/modules/beast_core/memory/CacheLine.h b/src/beast/modules/beast_core/memory/CacheLine.h
index dea39ebbb..fbc9c1914 100644
--- a/src/beast/modules/beast_core/memory/CacheLine.h
+++ b/src/beast/modules/beast_core/memory/CacheLine.h
@@ -30,10 +30,7 @@ namespace CacheLine
#if GLOBAL_PADDING_ENABLED
-// 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
@@ -42,83 +39,83 @@ class Aligned
public:
Aligned ()
{
- new (ptr ()) T;
+ new (&get()) T;
}
template
Aligned (T1 t1)
{
- new (ptr ()) T (t1);
+ new (&get()) T (t1);
}
template
Aligned (T1 t1, T2 t2)
{
- new (ptr ()) T (t1, t2);
+ new (&get()) T (t1, t2);
}
template
Aligned (T1 t1, T2 t2, T3 t3)
{
- new (ptr ()) T (t1, t2, t3);
+ new (&get()) T (t1, t2, t3);
}
template
Aligned (T1 t1, T2 t2, T3 t3, T4 t4)
{
- new (ptr ()) T (t1, t2, t3, t4);
+ new (&get()) T (t1, t2, t3, t4);
}
template
Aligned (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
{
- new (ptr ()) T (t1, t2, t3, t4, t5);
+ new (&get()) T (t1, t2, t3, t4, t5);
}
template
Aligned (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
{
- new (ptr ()) T (t1, t2, t3, t4, t5, t6);
+ new (&get()) T (t1, t2, t3, t4, t5, t6);
}
template
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);
+ new (&get()) T (t1, t2, t3, t4, t5, t6, t7);
}
template
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);
+ new (&get()) T (t1, t2, t3, t4, t5, t6, t7, t8);
}
~Aligned ()
{
- ptr ()->~T ();
+ get().~T ();
}
T& operator= (T const& other)
{
- *ptr () = other;
- return *ptr ();
+ return (get() = other);
}
- inline T& operator* () noexcept { return *ptr (); }
- inline T* operator-> () noexcept { return ptr (); }
- 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 T const& () const noexcept { return *ptr (); }
- inline operator T const* () const noexcept { return ptr (); }
+ T& get () noexcept { return *ptr(); }
+ T& operator* () noexcept { return get(); }
+ T* operator-> () noexcept { return &get(); }
+ operator T& () noexcept { return get(); }
+ operator T* () noexcept { return &get(); }
+ T const& get () const noexcept { return *ptr(); }
+ const T& operator* () const noexcept { return get(); }
+ const T* operator-> () const noexcept { return &get(); }
+ operator T const& () const noexcept { return get(); }
+ operator T const* () const noexcept { return &get(); }
private:
- inline T* ptr () noexcept
+ T* ptr () const noexcept
{
return (T*) ((uintptr_t (m_storage) + Memory::cacheLineAlignMask)
- & ~Memory::cacheLineAlignMask);
+ & ~Memory::cacheLineAlignMask);
/*
return reinterpret_cast (Memory::pointerAdjustedForAlignment (
m_storage, Memory::cacheLineBytes));
@@ -128,8 +125,9 @@ private:
char m_storage [ (sizeof (T) + Memory::cacheLineAlignMask) & ~Memory::cacheLineAlignMask];
};
-/** End-pads an object to completely fill straddling CPU cache lines.
+//------------------------------------------------------------------------------
+/** 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.
*/
@@ -195,15 +193,16 @@ public:
return m_t;
}
- T& operator* () noexcept { return m_t; }
- T* operator-> () noexcept { return &m_t; }
- 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 T const& () const noexcept { return m_t; }
- operator T const* () const noexcept { return &m_t; }
+ T& get() noexcept { return m_t;}
+ T& operator* () noexcept { return get(); }
+ T* operator-> () noexcept { return &get(); }
+ operator T& () noexcept { return get(); }
+ operator T* () noexcept { return &get(); }
+ T const& get () const noexcept { return m_t; }
+ const T& operator* () const noexcept { return get(); }
+ const T* operator-> () const noexcept { return &get(); }
+ operator T const& () const noexcept { return get(); }
+ operator T const* () const noexcept { return &get(); }
private:
T m_t;
@@ -257,32 +256,21 @@ public:
const T5& t5, const T6& t6, const T7& t7, const T8& t8)
: m_t (t1, t2, t3, t4, t5, t6, t7, t8) { }
- void operator= (const T& other)
+ T& operator= (const T& other)
{
- m_t = other;
+ reutrn (m_t = other);
}
- T& operator* () noexcept { return m_t; }
- T* operator-> () noexcept { return &m_t; }
- 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;
- }
+ T& get () noexcept { return m_t; }
+ T& operator* () noexcept { return get(); }
+ T* operator-> () noexcept { return &get(); }
+ operator T& () noexcept { return get(); }
+ operator T* () noexcept { return &get(); }
+ T const& get () const noexcept { return m_t; }
+ const T& operator* () const noexcept { return get(); }
+ const T* operator-> () const noexcept { return &get(); }
+ operator T const& () const noexcept { return get(); }
+ operator T const* () const noexcept { return &get(); }
private:
T m_t;
@@ -338,27 +326,16 @@ public:
m_t = other;
}
- T& operator* () noexcept { return m_t; }
- T* operator-> () noexcept { return &m_t; }
- 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;
- }
+ T& get () noexcept { return m_t; }
+ T& operator* () noexcept { return get(); }
+ T* operator-> () noexcept { return &get(); }
+ operator T& () noexcept { return get(); }
+ operator T* () noexcept { return &get(); }
+ T const& get () const noexcept { return m_t; }
+ const T& operator* () const noexcept { return get(); }
+ const T* operator-> () const noexcept { return &get(); }
+ operator T const& () const noexcept { return get(); }
+ operator T const* () const noexcept { return &get(); }
private:
T m_t;
@@ -415,44 +392,21 @@ public:
const T5& t5, const T6& t6, const T7& t7, const T8& t8)
: m_t (t1, t2, t3, t4, t5, t6, t7, t8) { }
- void operator= (const T& other)
+ T* operator= (const T& other)
{
- m_t = other;
+ return (m_t = other);
}
- T& operator* ()
- {
- return m_t;
- }
- T* operator-> ()
- {
- return &m_t;
- }
- operator T& ()
- {
- return m_t;
- }
- operator T* ()
- {
- return &m_t;
- }
-
- const T& operator* () const
- {
- return m_t;
- }
- const T* operator-> () const
- {
- return &m_t;
- }
- operator const T& () const
- {
- return m_t;
- }
- operator const T* () const
- {
- return &m_t;
- }
+ T& get () noexcept { return m_t; }
+ T& operator* () noexcept { return get(); }
+ T* operator-> () noexcept { return &get(); }
+ operator T& () noexcept { return get(); }
+ operator T* () noexcept { return &get(); }
+ T const& get () const noexcept { return m_t; }
+ const T& operator* () const noexcept { return get(); }
+ const T* operator-> () const noexcept { return &get(); }
+ operator T const& () const noexcept { return get(); }
+ operator T const* () const noexcept { return &get(); }
private:
T m_t;
diff --git a/src/beast/modules/beast_core/memory/PagedFreeStore.cpp b/src/beast/modules/beast_core/memory/PagedFreeStore.cpp
index 683f1c24e..8081ae4bf 100644
--- a/src/beast/modules/beast_core/memory/PagedFreeStore.cpp
+++ b/src/beast/modules/beast_core/memory/PagedFreeStore.cpp
@@ -181,7 +181,7 @@ void PagedFreeStore::onDeadlineTimer (DeadlineTimer&)
}
}
- m_cold->fresh->swap (m_cold->garbage);
+ std::swap (m_cold->fresh, m_cold->garbage);
// Swap atomically with respect to m_hot
Pool* temp = m_hot;
@@ -224,6 +224,6 @@ void PagedFreeStore::dispose (Pages& pages)
void PagedFreeStore::dispose (Pool& pool)
{
- dispose (pool.fresh);
- dispose (pool.garbage);
+ dispose (pool.fresh_c);
+ dispose (pool.garbage_c);
}
diff --git a/src/beast/modules/beast_core/memory/PagedFreeStore.h b/src/beast/modules/beast_core/memory/PagedFreeStore.h
index 8bfd8045e..d39eeee32 100644
--- a/src/beast/modules/beast_core/memory/PagedFreeStore.h
+++ b/src/beast/modules/beast_core/memory/PagedFreeStore.h
@@ -64,8 +64,16 @@ private:
struct Pool
{
- CacheLine::Padded fresh;
- CacheLine::Padded garbage;
+ Pool()
+ : fresh (&fresh_c.get())
+ , garbage (&garbage_c.get())
+ {
+ }
+
+ Pages* fresh;
+ Pages* garbage;
+ CacheLine::Padded fresh_c;
+ CacheLine::Padded garbage_c;
};
static inline void* fromPage (Page* const p);
diff --git a/src/beast/modules/beast_core/thread/CallQueue.cpp b/src/beast/modules/beast_core/thread/CallQueue.cpp
index 8540baa34..29216f76a 100644
--- a/src/beast/modules/beast_core/thread/CallQueue.cpp
+++ b/src/beast/modules/beast_core/thread/CallQueue.cpp
@@ -275,10 +275,10 @@ public:
};
}
- for (std::size_t i = 0; i < threads.size(); ++i)
+ for (int i = 0; i < threads.size(); ++i)
threads[i]->stop ();
- for (std::size_t i = 0; i < threads.size(); ++i)
+ for (int i = 0; i < threads.size(); ++i)
threads[i]->waitForThreadToExit();
double const secondsElapsed ((Time::getCurrentTime() - startTime).inSeconds ());
diff --git a/src/beast/modules/beast_core/thread/ThreadWithCallQueue.cpp b/src/beast/modules/beast_core/thread/ThreadWithCallQueue.cpp
index 25ccffa7f..c3753d2dc 100644
--- a/src/beast/modules/beast_core/thread/ThreadWithCallQueue.cpp
+++ b/src/beast/modules/beast_core/thread/ThreadWithCallQueue.cpp
@@ -222,7 +222,7 @@ public:
{
}
- void testThreads (std::size_t nThreads)
+ void testThreads (int nThreads)
{
beginTestCase (String::fromNumber (nThreads) + " threads");