General refactoring, using C++11

* Remove broken RecycledObjectPool

* Fix beast::ServiceQueue using List instead of LockFreeStack

* Add class semaphore, fixes broken Semaphore

* Move crytpo module files to new beast directory

* Use c++11 replacements for boost and beast types:
  - std::atomic instead of beast::Atomic
  - std::function instead of boost::function, beast::function
  - std::unique_ptr instead of beast::ScopedPointer
  - std::shared_ptr instead of boost::shared_ptr

* Remove modules:
  - beast_db
  - beast_crypto
  - beast_extras

* Remove unnecessary classes:
  - AbstractFifo
  - AddConst
  - AtomicCounter
  - AtomicFlag
  - AtomicPointer
  - AtomicState
  - CopyConst
  - Expression
  - ForwardList
  - IfCond
  - Interval
  - IntrusiveArray
  - KeyvaDB
  - PointerToOther
  - PointerTraits
  - RemoveConst
  - RemoveConstVolatile
  - RemoveReference
  - RemoveVolatile
  - SharedObjectArray
  - SingleThreadedSharedObject
  - SophiaDB factory
  - SortedSet
  - WeakReference
  - beast::unique_ptr
This commit is contained in:
Vinnie Falco
2013-12-31 08:28:12 -08:00
parent 52333b8bd4
commit 087301933a
164 changed files with 827 additions and 8812 deletions

View File

@@ -21,13 +21,15 @@
#define RIPPLE_BASICS_H_INCLUDED
#include "beast/modules/beast_core/beast_core.h"
#include "beast/modules/beast_crypto/beast_crypto.h"
#include "beast/beast/Crypto.h"
#include "beast/modules/beast_core/system/BeforeBoost.h"
#include "system/BoostIncludes.h"
#include "../../beast/beast/Utility.h"
#include <atomic>
#ifndef RIPPLE_TRACK_MUTEXES
# define RIPPLE_TRACK_MUTEXES 0
#endif

View File

@@ -25,6 +25,8 @@ CountedObjects& CountedObjects::getInstance ()
}
CountedObjects::CountedObjects ()
: m_count (0)
, m_head (nullptr)
{
}
@@ -38,11 +40,11 @@ CountedObjects::List CountedObjects::getCounts (int minimumThreshold) const
// When other operations are concurrent, the count
// might be temporarily less than the actual count.
int const count = m_count.get ();
int const count = m_count.load ();
counts.reserve (count);
CounterBase* counter = m_head.get ();
CounterBase* counter = m_head.load ();
while (counter != nullptr)
{
@@ -65,6 +67,7 @@ CountedObjects::List CountedObjects::getCounts (int minimumThreshold) const
//------------------------------------------------------------------------------
CountedObjects::CounterBase::CounterBase ()
: m_count (0)
{
// Insert ourselves at the front of the lock-free linked list
@@ -73,10 +76,10 @@ CountedObjects::CounterBase::CounterBase ()
do
{
head = instance.m_head.get ();
head = instance.m_head.load ();
m_next = head;
}
while (! instance.m_head.compareAndSetBool (this, head));
while (instance.m_head.exchange (this) != head);
++instance.m_count;
}
@@ -87,5 +90,3 @@ CountedObjects::CounterBase::~CounterBase ()
// undefined behavior will result if the singleton's member
// functions are called.
}
//------------------------------------------------------------------------------

View File

@@ -46,22 +46,22 @@ public:
virtual ~CounterBase ();
inline int increment () noexcept
int increment () noexcept
{
return ++m_count;
}
inline int decrement () noexcept
int decrement () noexcept
{
return --m_count;
}
inline int getCount () const noexcept
int getCount () const noexcept
{
return m_count.get ();
return m_count.load ();
}
inline CounterBase* getNext () const noexcept
CounterBase* getNext () const noexcept
{
return m_next;
}
@@ -72,18 +72,17 @@ public:
virtual void checkPureVirtual () const = 0;
protected:
beast::Atomic <int> m_count;
std::atomic <int> m_count;
CounterBase* m_next;
};
private:
CountedObjects ();
~CountedObjects ();
private:
beast::Atomic <int> m_count;
beast::Atomic <CounterBase*> m_head;
std::atomic <int> m_count;
std::atomic <CounterBase*> m_head;
};
//------------------------------------------------------------------------------

View File

@@ -20,33 +20,15 @@
#ifndef RIPPLE_PLATFORMMACROS_H
#define RIPPLE_PLATFORMMACROS_H
#define FUNCTION_TYPE beast::function
#define BIND_TYPE beast::bind
#define P_1 beast::_1
#define P_2 beast::_2
#define P_3 beast::_3
#define P_4 beast::_4
// VFALCO TODO Clean this up
#if (!defined(FORCE_NO_C11X) && (__cplusplus > 201100L)) || defined(FORCE_C11X)
// VFALCO TODO Get rid of the C11X macro
#define C11X
#define UPTR_T std::unique_ptr
#define MOVE_P(p) std::move(p)
#else
//#define UPTR_T std::auto_ptr
#define UPTR_T ScopedPointer
#define MOVE_P(p) (p)
#endif
// VFALCO TODO Clean this stuff up. Remove as much as possible
// DEPRECATED
#define nothing() do {} while (0)
#define fallthru() do {} while (0)
#define NUMBER(x) (sizeof(x)/sizeof((x)[0]))
#define isSetBit(x,y) (!!((x) & (y)))