mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
Detab beast
This commit is contained in:
committed by
Tom Ritchford
parent
f034b02b92
commit
75c8d7aa57
@@ -266,7 +266,7 @@ namespace detail {
|
|||||||
|
|
||||||
static double monotonicCurrentTimeInSeconds()
|
static double monotonicCurrentTimeInSeconds()
|
||||||
{
|
{
|
||||||
return GetTickCount64() / 1000.0;
|
return GetTickCount64() / 1000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -282,36 +282,36 @@ namespace detail {
|
|||||||
|
|
||||||
static double monotonicCurrentTimeInSeconds()
|
static double monotonicCurrentTimeInSeconds()
|
||||||
{
|
{
|
||||||
struct StaticInitializer
|
struct StaticInitializer
|
||||||
{
|
{
|
||||||
StaticInitializer ()
|
StaticInitializer ()
|
||||||
{
|
{
|
||||||
double numerator;
|
double numerator;
|
||||||
double denominator;
|
double denominator;
|
||||||
|
|
||||||
mach_timebase_info_data_t timebase;
|
mach_timebase_info_data_t timebase;
|
||||||
(void) mach_timebase_info (&timebase);
|
(void) mach_timebase_info (&timebase);
|
||||||
|
|
||||||
if (timebase.numer % 1000000 == 0)
|
if (timebase.numer % 1000000 == 0)
|
||||||
{
|
{
|
||||||
numerator = timebase.numer / 1000000.0;
|
numerator = timebase.numer / 1000000.0;
|
||||||
denominator = timebase.denom * 1000.0;
|
denominator = timebase.denom * 1000.0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
numerator = timebase.numer;
|
numerator = timebase.numer;
|
||||||
// VFALCO NOTE I don't understand this code
|
// VFALCO NOTE I don't understand this code
|
||||||
//denominator = timebase.denom * (std::uint64_t) 1000000 * 1000.0;
|
//denominator = timebase.denom * (std::uint64_t) 1000000 * 1000.0;
|
||||||
denominator = timebase.denom * 1000000000.0;
|
denominator = timebase.denom * 1000000000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ratio = numerator / denominator;
|
ratio = numerator / denominator;
|
||||||
}
|
}
|
||||||
|
|
||||||
double ratio;
|
double ratio;
|
||||||
};
|
};
|
||||||
|
|
||||||
static StaticInitializer const data;
|
static StaticInitializer const data;
|
||||||
|
|
||||||
return mach_absolute_time() * data.ratio;
|
return mach_absolute_time() * data.ratio;
|
||||||
}
|
}
|
||||||
@@ -327,9 +327,9 @@ namespace detail {
|
|||||||
|
|
||||||
static double monotonicCurrentTimeInSeconds()
|
static double monotonicCurrentTimeInSeconds()
|
||||||
{
|
{
|
||||||
timespec t;
|
timespec t;
|
||||||
clock_gettime (CLOCK_MONOTONIC, &t);
|
clock_gettime (CLOCK_MONOTONIC, &t);
|
||||||
return t.tv_sec + t.tv_nsec / 1000000000.0;
|
return t.tv_sec + t.tv_nsec / 1000000000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -343,26 +343,26 @@ namespace detail {
|
|||||||
// Records and returns the time from process startup
|
// Records and returns the time from process startup
|
||||||
static double getStartupTime()
|
static double getStartupTime()
|
||||||
{
|
{
|
||||||
struct StaticInitializer
|
struct StaticInitializer
|
||||||
{
|
{
|
||||||
StaticInitializer ()
|
StaticInitializer ()
|
||||||
{
|
{
|
||||||
when = detail::monotonicCurrentTimeInSeconds();
|
when = detail::monotonicCurrentTimeInSeconds();
|
||||||
}
|
}
|
||||||
|
|
||||||
double when;
|
double when;
|
||||||
};
|
};
|
||||||
|
|
||||||
static StaticInitializer const data;
|
static StaticInitializer const data;
|
||||||
|
|
||||||
return data.when;
|
return data.when;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to call getStartupTime as early as possible
|
// Used to call getStartupTime as early as possible
|
||||||
struct StartupTimeStaticInitializer
|
struct StartupTimeStaticInitializer
|
||||||
{
|
{
|
||||||
StartupTimeStaticInitializer ()
|
StartupTimeStaticInitializer ()
|
||||||
{
|
{
|
||||||
getStartupTime();
|
getStartupTime();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -373,7 +373,7 @@ static StartupTimeStaticInitializer startupTimeStaticInitializer;
|
|||||||
|
|
||||||
RelativeTime RelativeTime::fromStartup ()
|
RelativeTime RelativeTime::fromStartup ()
|
||||||
{
|
{
|
||||||
return RelativeTime (
|
return RelativeTime (
|
||||||
detail::monotonicCurrentTimeInSeconds() - detail::getStartupTime());
|
detail::monotonicCurrentTimeInSeconds() - detail::getStartupTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -141,154 +141,154 @@ Here is a short example demonstrating its use.
|
|||||||
\snippet cyclic_iterator.cpp cyclic_iterator
|
\snippet cyclic_iterator.cpp cyclic_iterator
|
||||||
*/
|
*/
|
||||||
template<
|
template<
|
||||||
typename ContainerIterator
|
typename ContainerIterator
|
||||||
>
|
>
|
||||||
class cyclic_iterator
|
class cyclic_iterator
|
||||||
:
|
:
|
||||||
public detail::cyclic_iterator_base<
|
public detail::cyclic_iterator_base<
|
||||||
ContainerIterator
|
ContainerIterator
|
||||||
>::type
|
>::type
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
\brief The base type which is a <code>boost::iterator_facade</code>
|
\brief The base type which is a <code>boost::iterator_facade</code>
|
||||||
*/
|
*/
|
||||||
typedef typename detail::cyclic_iterator_base<
|
typedef typename detail::cyclic_iterator_base<
|
||||||
ContainerIterator
|
ContainerIterator
|
||||||
>::type base_type;
|
>::type base_type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief The underlying iterator type
|
\brief The underlying iterator type
|
||||||
*/
|
*/
|
||||||
typedef ContainerIterator container_iterator_type;
|
typedef ContainerIterator container_iterator_type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief The value type adapted from \a ContainerIterator
|
\brief The value type adapted from \a ContainerIterator
|
||||||
*/
|
*/
|
||||||
typedef typename base_type::value_type value_type;
|
typedef typename base_type::value_type value_type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief The reference type adapted from \a ContainerIterator
|
\brief The reference type adapted from \a ContainerIterator
|
||||||
*/
|
*/
|
||||||
typedef typename base_type::reference reference;
|
typedef typename base_type::reference reference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief The pointer type adapted from \a ContainerIterator
|
\brief The pointer type adapted from \a ContainerIterator
|
||||||
*/
|
*/
|
||||||
typedef typename base_type::pointer pointer;
|
typedef typename base_type::pointer pointer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief The difference type adapted from \a ContainerIterator
|
\brief The difference type adapted from \a ContainerIterator
|
||||||
*/
|
*/
|
||||||
typedef typename base_type::difference_type difference_type;
|
typedef typename base_type::difference_type difference_type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief The iterator category, either Forward or Bidirectional
|
\brief The iterator category, either Forward or Bidirectional
|
||||||
*/
|
*/
|
||||||
typedef typename base_type::iterator_category iterator_category;
|
typedef typename base_type::iterator_category iterator_category;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Creates a singular iterator
|
\brief Creates a singular iterator
|
||||||
*/
|
*/
|
||||||
cyclic_iterator();
|
cyclic_iterator();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Copy constructs from another cyclic iterator
|
\brief Copy constructs from another cyclic iterator
|
||||||
|
|
||||||
Copy constructs from another cyclic iterator \a other. This only works
|
Copy constructs from another cyclic iterator \a other. This only works
|
||||||
if the underlying iterators are convertible.
|
if the underlying iterators are convertible.
|
||||||
|
|
||||||
\param other The iterator to copy construct from
|
\param other The iterator to copy construct from
|
||||||
*/
|
*/
|
||||||
template<
|
template<
|
||||||
typename OtherIterator
|
typename OtherIterator
|
||||||
>
|
>
|
||||||
explicit
|
explicit
|
||||||
cyclic_iterator(
|
cyclic_iterator(
|
||||||
cyclic_iterator<OtherIterator> const &other
|
cyclic_iterator<OtherIterator> const &other
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Constructs a new cyclic iterator
|
\brief Constructs a new cyclic iterator
|
||||||
|
|
||||||
Constructs a new cyclic iterator, starting at \a it, inside
|
Constructs a new cyclic iterator, starting at \a it, inside
|
||||||
a range from \a begin to \a end.
|
a range from \a begin to \a end.
|
||||||
|
|
||||||
\param pos The start of the iterator
|
\param pos The start of the iterator
|
||||||
\param begin The beginning of the range
|
\param begin The beginning of the range
|
||||||
\param end The end of the range
|
\param end The end of the range
|
||||||
|
|
||||||
\warning The behaviour is undefined if \a pos isn't between \a begin
|
\warning The behaviour is undefined if \a pos isn't between \a begin
|
||||||
and \a end. Also, the behaviour is undefined, if \a begin and \a end
|
and \a end. Also, the behaviour is undefined, if \a begin and \a end
|
||||||
don't form a valid range.
|
don't form a valid range.
|
||||||
*/
|
*/
|
||||||
cyclic_iterator(
|
cyclic_iterator(
|
||||||
container_iterator_type const &pos,
|
container_iterator_type const &pos,
|
||||||
container_iterator_type const &begin,
|
container_iterator_type const &begin,
|
||||||
container_iterator_type const &end
|
container_iterator_type const &end
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Assigns from another cyclic iterator
|
\brief Assigns from another cyclic iterator
|
||||||
|
|
||||||
Assigns from another cyclic iterator \a other. This only works if the
|
Assigns from another cyclic iterator \a other. This only works if the
|
||||||
underlying iterators are convertible.
|
underlying iterators are convertible.
|
||||||
|
|
||||||
\param other The iterator to assign from
|
\param other The iterator to assign from
|
||||||
|
|
||||||
\return <code>*this</code>
|
\return <code>*this</code>
|
||||||
*/
|
*/
|
||||||
template<
|
template<
|
||||||
typename OtherIterator
|
typename OtherIterator
|
||||||
>
|
>
|
||||||
cyclic_iterator<ContainerIterator> &
|
cyclic_iterator<ContainerIterator> &
|
||||||
operator=(
|
operator=(
|
||||||
cyclic_iterator<OtherIterator> const &other
|
cyclic_iterator<OtherIterator> const &other
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Returns the beginning of the range
|
\brief Returns the beginning of the range
|
||||||
*/
|
*/
|
||||||
container_iterator_type
|
container_iterator_type
|
||||||
begin() const;
|
begin() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Returns the end of the range
|
\brief Returns the end of the range
|
||||||
*/
|
*/
|
||||||
container_iterator_type
|
container_iterator_type
|
||||||
end() const;
|
end() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Returns the underlying iterator
|
\brief Returns the underlying iterator
|
||||||
*/
|
*/
|
||||||
container_iterator_type
|
container_iterator_type
|
||||||
get() const;
|
get() const;
|
||||||
private:
|
private:
|
||||||
friend class boost::iterator_core_access;
|
friend class boost::iterator_core_access;
|
||||||
|
|
||||||
void
|
void
|
||||||
increment();
|
increment();
|
||||||
|
|
||||||
void
|
void
|
||||||
decrement();
|
decrement();
|
||||||
|
|
||||||
bool
|
bool
|
||||||
equal(
|
equal(
|
||||||
cyclic_iterator const &
|
cyclic_iterator const &
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
reference
|
reference
|
||||||
dereference() const;
|
dereference() const;
|
||||||
|
|
||||||
difference_type
|
difference_type
|
||||||
distance_to(
|
distance_to(
|
||||||
cyclic_iterator const &
|
cyclic_iterator const &
|
||||||
) const;
|
) const;
|
||||||
private:
|
private:
|
||||||
container_iterator_type
|
container_iterator_type
|
||||||
it_,
|
it_,
|
||||||
begin_,
|
begin_,
|
||||||
end_;
|
end_;
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ void SpookyHash::Hash128(
|
|||||||
while (u.p64 < end)
|
while (u.p64 < end)
|
||||||
{
|
{
|
||||||
Mix(u.p64, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
|
Mix(u.p64, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
|
||||||
u.p64 += sc_numVars;
|
u.p64 += sc_numVars;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -175,7 +175,7 @@ void SpookyHash::Hash128(
|
|||||||
{
|
{
|
||||||
memcpy(buf, u.p64, sc_blockSize);
|
memcpy(buf, u.p64, sc_blockSize);
|
||||||
Mix(buf, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
|
Mix(buf, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
|
||||||
u.p64 += sc_numVars;
|
u.p64 += sc_numVars;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +275,7 @@ void SpookyHash::Update(const void *message, size_t length)
|
|||||||
while (u.p64 < end)
|
while (u.p64 < end)
|
||||||
{
|
{
|
||||||
Mix(u.p64, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
|
Mix(u.p64, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
|
||||||
u.p64 += sc_numVars;
|
u.p64 += sc_numVars;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -284,7 +284,7 @@ void SpookyHash::Update(const void *message, size_t length)
|
|||||||
{
|
{
|
||||||
memcpy(m_data, u.p8, sc_blockSize);
|
memcpy(m_data, u.p8, sc_blockSize);
|
||||||
Mix(m_data, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
|
Mix(m_data, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
|
||||||
u.p64 += sc_numVars;
|
u.p64 += sc_numVars;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ typedef std::array <std::uint8_t, digestLength> digest_type;
|
|||||||
namespace detail {
|
namespace detail {
|
||||||
struct Context
|
struct Context
|
||||||
{
|
{
|
||||||
std::uint32_t state[8];
|
std::uint32_t state[8];
|
||||||
std::uint64_t bitcount;
|
std::uint64_t bitcount;
|
||||||
std::uint8_t buffer[Sha256::blockLength];
|
std::uint8_t buffer[Sha256::blockLength];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,14 +154,14 @@ void subtract_integer(integer left, integer right, integer result) {
|
|||||||
double_component_t lhs = left.c[i];
|
double_component_t lhs = left.c[i];
|
||||||
double_component_t rhs = (i < right.num_components) ? right.c[i] : 0;
|
double_component_t rhs = (i < right.num_components) ? right.c[i] : 0;
|
||||||
if (borrow) {
|
if (borrow) {
|
||||||
if (lhs <= rhs) {
|
if (lhs <= rhs) {
|
||||||
/* leave borrow set to 1 */
|
/* leave borrow set to 1 */
|
||||||
lhs += (MAX_COMPONENT + 1) - 1;
|
lhs += (MAX_COMPONENT + 1) - 1;
|
||||||
} else {
|
} else {
|
||||||
borrow = 0;
|
borrow = 0;
|
||||||
lhs--;
|
lhs--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lhs < rhs) {
|
if (lhs < rhs) {
|
||||||
borrow = 1;
|
borrow = 1;
|
||||||
lhs += MAX_COMPONENT + 1;
|
lhs += MAX_COMPONENT + 1;
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ is_white (CharT c)
|
|||||||
case '\r': case '\t': case '\v':
|
case '\r': case '\t': case '\v':
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns `true` if `c` is a control character. */
|
/** Returns `true` if `c` is a control character. */
|
||||||
@@ -85,24 +85,24 @@ template <class FwdIter>
|
|||||||
FwdIter
|
FwdIter
|
||||||
trim_left (FwdIter first, FwdIter last)
|
trim_left (FwdIter first, FwdIter last)
|
||||||
{
|
{
|
||||||
return std::find_if_not (first, last,
|
return std::find_if_not (first, last,
|
||||||
&is_white <typename FwdIter::value_type>);
|
&is_white <typename FwdIter::value_type>);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class FwdIter>
|
template <class FwdIter>
|
||||||
FwdIter
|
FwdIter
|
||||||
trim_right (FwdIter first, FwdIter last)
|
trim_right (FwdIter first, FwdIter last)
|
||||||
{
|
{
|
||||||
if (first == last)
|
if (first == last)
|
||||||
return last;
|
return last;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
--last;
|
--last;
|
||||||
if (! is_white (*last))
|
if (! is_white (*last))
|
||||||
return ++last;
|
return ++last;
|
||||||
}
|
}
|
||||||
while (last != first);
|
while (last != first);
|
||||||
return first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class CharT, class Traits, class Allocator>
|
template <class CharT, class Traits, class Allocator>
|
||||||
@@ -118,9 +118,9 @@ template <class FwdIter>
|
|||||||
std::pair <FwdIter, FwdIter>
|
std::pair <FwdIter, FwdIter>
|
||||||
trim (FwdIter first, FwdIter last)
|
trim (FwdIter first, FwdIter last)
|
||||||
{
|
{
|
||||||
first = trim_left (first, last);
|
first = trim_left (first, last);
|
||||||
last = trim_right (first, last);
|
last = trim_right (first, last);
|
||||||
return std::make_pair (first, last);
|
return std::make_pair (first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class String>
|
template <class String>
|
||||||
@@ -131,7 +131,7 @@ trim (String const& s)
|
|||||||
using std::end;
|
using std::end;
|
||||||
auto first (begin(s));
|
auto first (begin(s));
|
||||||
auto last (end(s));
|
auto last (end(s));
|
||||||
std::tie (first, last) = trim (first, last);
|
std::tie (first, last) = trim (first, last);
|
||||||
return { first, last };
|
return { first, last };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ trim_right (String const& s)
|
|||||||
using std::end;
|
using std::end;
|
||||||
auto first (begin(s));
|
auto first (begin(s));
|
||||||
auto last (end(s));
|
auto last (end(s));
|
||||||
last = trim_right (first, last);
|
last = trim_right (first, last);
|
||||||
return { first, last };
|
return { first, last };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace http {
|
|||||||
std::vector <char const*> const&
|
std::vector <char const*> const&
|
||||||
urls_large_data()
|
urls_large_data()
|
||||||
{
|
{
|
||||||
static std::vector <char const*> const urls ({
|
static std::vector <char const*> const urls ({
|
||||||
"google.com",
|
"google.com",
|
||||||
"facebook.com",
|
"facebook.com",
|
||||||
"youtube.com",
|
"youtube.com",
|
||||||
@@ -10030,7 +10030,7 @@ urls_large_data()
|
|||||||
"18schoolgirlz.com"
|
"18schoolgirlz.com"
|
||||||
});
|
});
|
||||||
|
|
||||||
return urls;
|
return urls;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -247,8 +247,8 @@ private:
|
|||||||
|
|
||||||
static HiResCounterHandler& hiResCounterHandler()
|
static HiResCounterHandler& hiResCounterHandler()
|
||||||
{
|
{
|
||||||
static HiResCounterHandler hiResCounterHandler;
|
static HiResCounterHandler hiResCounterHandler;
|
||||||
return hiResCounterHandler;
|
return hiResCounterHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint32_t beast_millisecondsSinceStartup() noexcept { return hiResCounterHandler().millisecondsSinceStartup(); }
|
std::uint32_t beast_millisecondsSinceStartup() noexcept { return hiResCounterHandler().millisecondsSinceStartup(); }
|
||||||
|
|||||||
@@ -352,7 +352,7 @@ protected:
|
|||||||
|
|
||||||
void wait();
|
void wait();
|
||||||
virtual void enqueue (Item* item);
|
virtual void enqueue (Item* item);
|
||||||
bool empty();
|
bool empty();
|
||||||
|
|
||||||
virtual std::size_t dequeue() = 0;
|
virtual std::size_t dequeue() = 0;
|
||||||
virtual Waiter* new_waiter() = 0;
|
virtual Waiter* new_waiter() = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user