mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-02 08:55:53 +00:00
Migrate some headers and general tidying
This commit is contained in:
@@ -69,12 +69,17 @@
|
||||
<None Include="..\..\README.md" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\beast\Atomic.h" />
|
||||
<ClInclude Include="..\..\beast\Config.h" />
|
||||
<ClInclude Include="..\..\beast\CStdInt.h" />
|
||||
<ClInclude Include="..\..\beast\Intrusive.h" />
|
||||
<ClInclude Include="..\..\beast\intrusive\ForwardList.h" />
|
||||
<ClInclude Include="..\..\beast\intrusive\List.h" />
|
||||
<ClInclude Include="..\..\beast\intrusive\LockFreeStack.h" />
|
||||
<ClInclude Include="..\..\beast\intrusive\PointerTraits.h" />
|
||||
<ClInclude Include="..\..\beast\MPL.h" />
|
||||
<ClInclude Include="..\..\beast\mpl\AddConst.h" />
|
||||
<ClInclude Include="..\..\beast\mpl\CopyConst.h" />
|
||||
<ClInclude Include="..\..\beast\mpl\IfCond.h" />
|
||||
<ClInclude Include="..\..\beast\mpl\IsCallPossible.h" />
|
||||
<ClInclude Include="..\..\beast\mpl\PointerToOther.h" />
|
||||
@@ -155,14 +160,10 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\containers\ArrayAllocationBase.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\containers\DynamicObject.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\containers\ElementComparator.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\containers\detail\copyconst.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\containers\detail\removecv.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\containers\DynamicArray.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\containers\HashMap.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\containers\LinkedListPointer.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\containers\List.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\containers\LockFreeQueue.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\containers\LockFreeStack.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\containers\NamedValueSet.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\containers\OwnedArray.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\containers\PropertySet.h" />
|
||||
@@ -208,7 +209,6 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\Range.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\uint24.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\AllocatedBy.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\Atomic.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\AtomicCounter.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\AtomicFlag.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\AtomicPointer.h" />
|
||||
|
||||
@@ -165,9 +165,6 @@
|
||||
<Filter Include="beast_extras\traits">
|
||||
<UniqueIdentifier>{bf498396-2e1f-4903-be68-3053ba439af5}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="beast_core\containers\detail">
|
||||
<UniqueIdentifier>{08ec13ba-4058-4ad7-afbb-cbb1c6e2fc4a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="beast">
|
||||
<UniqueIdentifier>{92d1bb42-289a-4444-85c7-cb87540f2fff}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@@ -296,9 +293,6 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\Range.h">
|
||||
<Filter>beast_core\maths</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\Atomic.h">
|
||||
<Filter>beast_core\memory</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\ByteOrder.h">
|
||||
<Filter>beast_core\memory</Filter>
|
||||
</ClInclude>
|
||||
@@ -549,9 +543,6 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\containers\LockFreeQueue.h">
|
||||
<Filter>beast_core\containers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\containers\LockFreeStack.h">
|
||||
<Filter>beast_core\containers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\threads\SpinDelay.h">
|
||||
<Filter>beast_core\threads</Filter>
|
||||
</ClInclude>
|
||||
@@ -822,15 +813,6 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\containers\HashMap.h">
|
||||
<Filter>beast_core\containers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\containers\List.h">
|
||||
<Filter>beast_core\containers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\containers\detail\copyconst.h">
|
||||
<Filter>beast_core\containers\detail</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\containers\detail\removecv.h">
|
||||
<Filter>beast_core\containers\detail</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\text\StringCharPointerType.h">
|
||||
<Filter>beast_core\text</Filter>
|
||||
</ClInclude>
|
||||
@@ -1104,6 +1086,21 @@
|
||||
<ClInclude Include="..\..\modules\beast_asio\basics\SharedArg.h">
|
||||
<Filter>beast_asio\basics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\Intrusive.h">
|
||||
<Filter>beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\Atomic.h">
|
||||
<Filter>beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\intrusive\LockFreeStack.h">
|
||||
<Filter>beast\intrusive</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\intrusive\List.h">
|
||||
<Filter>beast\intrusive</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\mpl\CopyConst.h">
|
||||
<Filter>beast\mpl</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\modules\beast_core\containers\AbstractFifo.cpp">
|
||||
|
||||
@@ -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
|
||||
@@ -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 <typename T>
|
||||
struct removecv
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct removecv <const T>
|
||||
{
|
||||
typedef typename removecv <T>::type type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct removecv <volatile T>
|
||||
{
|
||||
typedef typename removecv <T>::type type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct removecv <const volatile T>
|
||||
{
|
||||
typedef typename removecv <T>::type type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct removecv <T*>
|
||||
{
|
||||
typedef typename removecv <T>::type type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct removecv <T&>
|
||||
{
|
||||
typedef typename removecv <T>::type type;
|
||||
};
|
||||
|
||||
#if BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS
|
||||
template <typename T>
|
||||
struct removecv <T&&>
|
||||
{
|
||||
typedef typename removecv <T>::type type;
|
||||
};
|
||||
#endif
|
||||
|
||||
}
|
||||
#include "intrusive/ForwardList.h"
|
||||
#include "intrusive/List.h"
|
||||
#include "intrusive/LockFreeStack.h"
|
||||
|
||||
#endif
|
||||
@@ -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"
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#define BEAST_INTRUSIVE_FORWARDLIST_H_INCLUDED
|
||||
|
||||
#include <iterator>
|
||||
|
||||
#include "PointerTraits.h"
|
||||
#include "../MPL.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 <iterator>
|
||||
#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 <N, typename N::value_type>::type
|
||||
|
||||
typedef typename mpl::CopyConst<N, typename N::value_type>::type
|
||||
value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef value_type& reference;
|
||||
@@ -243,14 +248,6 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
#if 0
|
||||
template <typename M>
|
||||
ListIterator& operator= (ListIterator <M> const& other) noexcept
|
||||
{
|
||||
m_node = other.m_node;
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
template <typename M>
|
||||
bool operator== (ListIterator <M> 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
|
||||
@@ -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 <iterator>
|
||||
#include "../mpl/IfCond.h"
|
||||
#include "../Atomic.h"
|
||||
#include "../Uncopyable.h"
|
||||
|
||||
/*============================================================================*/
|
||||
namespace beast {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template <class Container, bool IsConst>
|
||||
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 <LockFreeStackIterator&> (*this);
|
||||
}
|
||||
|
||||
@@ -85,16 +90,9 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
template <bool OtherIsConst>
|
||||
bool operator== (LockFreeStackIterator <Container, OtherIsConst> const& other)
|
||||
NodePtr node() const
|
||||
{
|
||||
return m_node == other.m_node;
|
||||
}
|
||||
|
||||
template <bool OtherIsConst>
|
||||
bool operator!= (LockFreeStackIterator <Container, OtherIsConst> 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 <class Container, bool LhsIsConst, bool RhsIsConst>
|
||||
bool operator== (LockFreeStackIterator <Container, LhsIsConst> const& lhs,
|
||||
LockFreeStackIterator <Container, RhsIsConst> const& rhs)
|
||||
{
|
||||
return lhs.node() == rhs.node();
|
||||
}
|
||||
|
||||
The caller is responsible for preventing the "ABA" problem
|
||||
(http://en.wikipedia.org/wiki/ABA_problem)
|
||||
template <class Container, bool LhsIsConst, bool RhsIsConst>
|
||||
bool operator!= (LockFreeStackIterator <Container, LhsIsConst> const& lhs,
|
||||
LockFreeStackIterator <Container, RhsIsConst> const& rhs)
|
||||
{
|
||||
return lhs.node() != rhs.node();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** 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.
|
||||
|
||||
@ingroup beast_core intrusive
|
||||
*/
|
||||
template <class Element, class Tag = void>
|
||||
class LockFreeStack : public Uncopyable
|
||||
@@ -147,8 +160,7 @@ public:
|
||||
template <class Container, bool IsConst>
|
||||
friend class LockFreeStackIterator;
|
||||
|
||||
// VFALCO TODO Use regular Atomic<>
|
||||
AtomicPointer <Node> m_next;
|
||||
Atomic <Node*> m_next;
|
||||
};
|
||||
|
||||
public:
|
||||
@@ -164,36 +176,15 @@ public:
|
||||
typedef LockFreeStackIterator <
|
||||
LockFreeStack <Element, Tag>, 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 <Element*> (node) : nullptr;
|
||||
return static_cast <Element*> (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 <size_type> m_size;
|
||||
AtomicPointer <Node> m_head;
|
||||
Atomic <Node*> m_head;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -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 <typename T>
|
||||
struct AddConst
|
||||
{
|
||||
typedef T const type;
|
||||
typedef typename RemoveConst<T>::type const type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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 <typename T, typename U>
|
||||
struct copyconst
|
||||
struct CopyConst
|
||||
{
|
||||
typedef typename removecv <U>::type type;
|
||||
typedef typename RemoveConst<U>::type type;
|
||||
};
|
||||
|
||||
template <typename T, typename U>
|
||||
struct copyconst <T const, U>
|
||||
struct CopyConst <T const, U>
|
||||
{
|
||||
typedef typename removecv <U>::type const type;
|
||||
typedef typename RemoveConst<U>::type const type;
|
||||
};
|
||||
/** @} */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -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 <bool Condition, typename T1, typename T2>
|
||||
struct IfCond
|
||||
{
|
||||
@@ -38,7 +38,7 @@ struct IfCond <false, T1, T2>
|
||||
{
|
||||
typedef T2 type;
|
||||
};
|
||||
/// @}
|
||||
/** @} */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace mpl {
|
||||
parameters. More specializations can be added for containers with
|
||||
more than three template parameters.
|
||||
*/
|
||||
/// @{
|
||||
/** @{ */
|
||||
template <class T, class U>
|
||||
struct PointerToOther;
|
||||
|
||||
@@ -60,7 +60,7 @@ struct PointerToOther <T*, U>
|
||||
{
|
||||
typedef U* type;
|
||||
};
|
||||
/// @}
|
||||
/** @} */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
namespace beast {
|
||||
namespace mpl {
|
||||
|
||||
/// Remove the `const` qualifier from a type.
|
||||
/// @{
|
||||
/** Remove the `const` qualifier from a type. */
|
||||
/** @{ */
|
||||
template <typename T>
|
||||
struct RemoveConst
|
||||
{
|
||||
@@ -38,7 +38,7 @@ struct RemoveConst <T const>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
/// @}
|
||||
/** @} */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 <typename T>
|
||||
struct RemoveConstVolatile
|
||||
{
|
||||
|
||||
@@ -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 <class T>
|
||||
struct RemoveReference
|
||||
{
|
||||
@@ -38,7 +38,7 @@ struct RemoveReference <T&>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
/// @}
|
||||
/** @} */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
namespace beast {
|
||||
namespace mpl {
|
||||
|
||||
/// Remove the `volatile` qualifier from a type.
|
||||
/// @{
|
||||
/** Remove the `volatile` qualifier from a type. */
|
||||
/** @{ */
|
||||
template <typename T>
|
||||
struct RemoveVolatile
|
||||
{
|
||||
@@ -38,7 +38,7 @@ struct RemoveVolatile <T volatile>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
/// @}
|
||||
/** @} */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,8 +120,6 @@ public:
|
||||
template <typename IntegralType>
|
||||
Proxy& operator= (IntegralType v)
|
||||
{
|
||||
bassert (v >= 0 && v <= 255);
|
||||
|
||||
(*m_value)=
|
||||
(*m_value)&(!((0xff)<<m_shift)) |
|
||||
((v&0xff)<<m_shift);
|
||||
|
||||
@@ -20,8 +20,7 @@
|
||||
#ifndef BEAST_TYPE_TRAITS_INTEGRALCONSTANT_H_INCLUDED
|
||||
#define BEAST_TYPE_TRAITS_INTEGRALCONSTANT_H_INCLUDED
|
||||
|
||||
namespace beast
|
||||
{
|
||||
namespace beast {
|
||||
|
||||
// ideas from boost
|
||||
|
||||
|
||||
@@ -22,10 +22,7 @@
|
||||
|
||||
#include "IntegralConstant.h"
|
||||
|
||||
namespace beast
|
||||
{
|
||||
|
||||
namespace detail
|
||||
namespace beast {
|
||||
|
||||
template <typename T> struct IsIntegral : FalseType { };
|
||||
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
|
||||
#include "IntegralConstant.h"
|
||||
|
||||
namespace beast
|
||||
{
|
||||
namespace beast {
|
||||
|
||||
template <typename T> struct IsSigned : FalseType { };
|
||||
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
|
||||
#include "IntegralConstant.h"
|
||||
|
||||
namespace beast
|
||||
{
|
||||
namespace beast {
|
||||
|
||||
/** Returns an equally sized, unsigned type.
|
||||
Requires:
|
||||
@@ -33,12 +32,12 @@ template <typename T>
|
||||
struct RemoveSigned
|
||||
{
|
||||
typedef T type;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct RemoveSigned <int8> { typedef uint8 type; }
|
||||
template <> struct RemoveSigned <int16> { typedef uint16 type; }
|
||||
template <> struct RemoveSigned <int32> { typedef uint32 type; }
|
||||
template <> struct RemoveSigned <int64> { typedef uint64 type; }
|
||||
template <> struct RemoveSigned <int8> { typedef uint8 type; };
|
||||
template <> struct RemoveSigned <int16> { typedef uint16 type; };
|
||||
template <> struct RemoveSigned <int32> { typedef uint32 type; };
|
||||
template <> struct RemoveSigned <int64> { typedef uint64 type; };
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class DynamicArrayIterator
|
||||
typename V::size_type>
|
||||
{
|
||||
public:
|
||||
typedef typename copyconst <V, typename V::value_type>::type
|
||||
typedef typename mpl::CopyConst <V, typename V::value_type>::type
|
||||
|
||||
value_type;
|
||||
typedef value_type* pointer;
|
||||
@@ -216,7 +216,7 @@ class DynamicArrayReverseIterator
|
||||
typename V::size_type>
|
||||
{
|
||||
public:
|
||||
typedef typename copyconst <V, typename V::value_type>::type
|
||||
typedef typename mpl::CopyConst<V, typename V::value_type>::type
|
||||
|
||||
value_type;
|
||||
typedef value_type* pointer;
|
||||
|
||||
@@ -193,9 +193,9 @@ class HashMapIterator
|
||||
private:
|
||||
typedef typename M::Item Item;
|
||||
typedef typename M::Bucket Bucket;
|
||||
typedef detail::ListIterator <typename detail::copyconst <M,
|
||||
typedef detail::ListIterator <typename mpl::CopyConst <M,
|
||||
typename List <Bucket>::Node>::type> bucket_iterator;
|
||||
typedef detail::ListIterator <typename detail::copyconst <M,
|
||||
typedef detail::ListIterator <typename mpl::CopyConst <M,
|
||||
typename List <Item, detail::BucketTag>::Node>::type> item_iterator;
|
||||
|
||||
public:
|
||||
|
||||
@@ -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 <class Element, class Tag = LockFreeQueueDefaultTag>
|
||||
template <class Element, class Tag = void>
|
||||
class LockFreeQueue
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -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 <typename T>
|
||||
@@ -42,80 +39,80 @@ class Aligned
|
||||
public:
|
||||
Aligned ()
|
||||
{
|
||||
new (ptr ()) T;
|
||||
new (&get()) T;
|
||||
}
|
||||
|
||||
template <class T1>
|
||||
Aligned (T1 t1)
|
||||
{
|
||||
new (ptr ()) T (t1);
|
||||
new (&get()) T (t1);
|
||||
}
|
||||
|
||||
template <class T1, class T2>
|
||||
Aligned (T1 t1, T2 t2)
|
||||
{
|
||||
new (ptr ()) T (t1, t2);
|
||||
new (&get()) T (t1, t2);
|
||||
}
|
||||
|
||||
template <class T1, class T2, class T3>
|
||||
Aligned (T1 t1, T2 t2, T3 t3)
|
||||
{
|
||||
new (ptr ()) T (t1, t2, t3);
|
||||
new (&get()) T (t1, t2, t3);
|
||||
}
|
||||
|
||||
template <class T1, class T2, class T3, class T4>
|
||||
Aligned (T1 t1, T2 t2, T3 t3, T4 t4)
|
||||
{
|
||||
new (ptr ()) T (t1, t2, t3, t4);
|
||||
new (&get()) T (t1, t2, t3, t4);
|
||||
}
|
||||
|
||||
template <class T1, class T2, class T3, class T4, class T5>
|
||||
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 <class T1, class T2, class T3, class T4, class T5, class T6>
|
||||
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 <class T1, class T2, class T3, class T4, class T5, class T6, class T7>
|
||||
Aligned (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
|
||||
{
|
||||
new (ptr ()) T (t1, t2, t3, t4, t5, t6, t7);
|
||||
new (&get()) T (t1, t2, t3, t4, t5, t6, t7);
|
||||
}
|
||||
|
||||
template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8>
|
||||
Aligned (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);
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -64,8 +64,16 @@ private:
|
||||
|
||||
struct Pool
|
||||
{
|
||||
CacheLine::Padded <Pages> fresh;
|
||||
CacheLine::Padded <Pages> garbage;
|
||||
Pool()
|
||||
: fresh (&fresh_c.get())
|
||||
, garbage (&garbage_c.get())
|
||||
{
|
||||
}
|
||||
|
||||
Pages* fresh;
|
||||
Pages* garbage;
|
||||
CacheLine::Padded <Pages> fresh_c;
|
||||
CacheLine::Padded <Pages> garbage_c;
|
||||
};
|
||||
|
||||
static inline void* fromPage (Page* const p);
|
||||
|
||||
@@ -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 ());
|
||||
|
||||
@@ -222,7 +222,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void testThreads (std::size_t nThreads)
|
||||
void testThreads (int nThreads)
|
||||
{
|
||||
beginTestCase (String::fromNumber (nThreads) + " threads");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user