refactor: Align identifier naming with develop

Apply readability-identifier-naming clang-tidy check to branch-modified
files (and their transitive includes) in preparation for merging develop.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Pratik Mankawde
2026-05-05 13:43:49 +01:00
parent e9210ccb2e
commit 87f4a482c1
318 changed files with 12037 additions and 11874 deletions

View File

@@ -1,13 +1,11 @@
---
# This entire group of checks was applied to all cpp files but not all header files.
# ---
Checks: "-*,
bugprone-argument-comment,
bugprone-assert-side-effect,
bugprone-bad-signal-to-kill-thread,
bugprone-bool-pointer-implicit-conversion,
bugprone-casting-through-void,
bugprone-capturing-this-in-member-variable,
bugprone-casting-through-void,
bugprone-chained-comparison,
bugprone-compare-pointer-to-member-virtual-function,
bugprone-copy-constructor-init,
@@ -26,10 +24,10 @@ Checks: "-*,
bugprone-lambda-function-name,
bugprone-macro-parentheses,
bugprone-macro-repeated-side-effects,
bugprone-misleading-setter-of-reference,
bugprone-misplaced-operator-in-strlen-in-alloc,
bugprone-misplaced-pointer-arithmetic-in-alloc,
bugprone-misplaced-widening-cast,
bugprone-misleading-setter-of-reference,
bugprone-move-forwarding-reference,
bugprone-multi-level-implicit-pointer-conversion,
bugprone-multiple-new-in-one-expression,
@@ -75,10 +73,10 @@ Checks: "-*,
bugprone-unhandled-self-assignment,
bugprone-unique-ptr-array-mismatch,
bugprone-unsafe-functions,
bugprone-use-after-move,
bugprone-unused-local-non-trivial-variable,
bugprone-unused-raii,
bugprone-unused-return-value,
bugprone-unused-local-non-trivial-variable,
bugprone-use-after-move,
bugprone-virtual-near-miss,
cppcoreguidelines-init-variables,
cppcoreguidelines-misleading-capture-default-by-value,
@@ -90,6 +88,7 @@ Checks: "-*,
cppcoreguidelines-use-enum-class,
cppcoreguidelines-virtual-class-destructor,
hicpp-ignored-remove-result,
llvm-namespace-comment,
misc-const-correctness,
misc-definitions-in-headers,
misc-header-include-cycle,
@@ -101,6 +100,7 @@ Checks: "-*,
misc-unused-alias-decls,
misc-unused-using-decls,
modernize-concat-nested-namespaces,
modernize-deprecated-headers,
modernize-make-shared,
modernize-make-unique,
modernize-pass-by-value,
@@ -116,8 +116,6 @@ Checks: "-*,
modernize-use-starts-ends-with,
modernize-use-std-numbers,
modernize-use-using,
modernize-deprecated-headers,
llvm-namespace-comment,
performance-faster-string-find,
performance-for-range-copy,
performance-implicit-conversion-in-loop,
@@ -137,6 +135,7 @@ Checks: "-*,
readability-duplicate-include,
readability-else-after-return,
readability-enum-initial-value,
readability-identifier-naming,
readability-implicit-bool-conversion,
readability-make-member-function-const,
readability-math-missing-parentheses,
@@ -154,52 +153,47 @@ Checks: "-*,
readability-use-std-min-max
"
# ---
# other checks that have issues that need to be resolved:
#
# readability-inconsistent-declaration-parameter-name, # in this codebase this check will break a lot of arg names
# readability-static-accessed-through-instance, # this check is probably unnecessary. it makes the code less readable
# readability-identifier-naming, # https://github.com/XRPLF/rippled/pull/6571
# ---
#
CheckOptions:
readability-braces-around-statements.ShortStatementLines: 2
# readability-identifier-naming.MacroDefinitionCase: UPPER_CASE
# readability-identifier-naming.ClassCase: CamelCase
# readability-identifier-naming.StructCase: CamelCase
# readability-identifier-naming.UnionCase: CamelCase
# readability-identifier-naming.EnumCase: CamelCase
# readability-identifier-naming.EnumConstantCase: CamelCase
# readability-identifier-naming.ScopedEnumConstantCase: CamelCase
# readability-identifier-naming.GlobalConstantCase: UPPER_CASE
# readability-identifier-naming.GlobalConstantPrefix: "k"
# readability-identifier-naming.GlobalVariableCase: CamelCase
# readability-identifier-naming.GlobalVariablePrefix: "g"
# readability-identifier-naming.ConstexprFunctionCase: camelBack
# readability-identifier-naming.ConstexprMethodCase: camelBack
# readability-identifier-naming.ClassMethodCase: camelBack
# readability-identifier-naming.ClassMemberCase: camelBack
# readability-identifier-naming.ClassConstantCase: UPPER_CASE
# readability-identifier-naming.ClassConstantPrefix: "k"
# readability-identifier-naming.StaticConstantCase: UPPER_CASE
# readability-identifier-naming.StaticConstantPrefix: "k"
# readability-identifier-naming.StaticVariableCase: UPPER_CASE
# readability-identifier-naming.StaticVariablePrefix: "k"
# readability-identifier-naming.ConstexprVariableCase: UPPER_CASE
# readability-identifier-naming.ConstexprVariablePrefix: "k"
# readability-identifier-naming.LocalConstantCase: camelBack
# readability-identifier-naming.LocalVariableCase: camelBack
# readability-identifier-naming.TemplateParameterCase: CamelCase
# readability-identifier-naming.ParameterCase: camelBack
# readability-identifier-naming.FunctionCase: camelBack
# readability-identifier-naming.MemberCase: camelBack
# readability-identifier-naming.PrivateMemberSuffix: _
# readability-identifier-naming.ProtectedMemberSuffix: _
# readability-identifier-naming.PublicMemberSuffix: ""
# readability-identifier-naming.FunctionIgnoredRegexp: ".*tag_invoke.*"
readability-identifier-naming.MacroDefinitionCase: UPPER_CASE
readability-identifier-naming.ClassCase: CamelCase
readability-identifier-naming.StructCase: CamelCase
readability-identifier-naming.UnionCase: CamelCase
readability-identifier-naming.EnumCase: CamelCase
readability-identifier-naming.EnumConstantCase: CamelCase
readability-identifier-naming.ScopedEnumConstantCase: CamelCase
readability-identifier-naming.GlobalConstantCase: UPPER_CASE
readability-identifier-naming.GlobalConstantPrefix: "k"
readability-identifier-naming.GlobalVariableCase: CamelCase
readability-identifier-naming.GlobalVariablePrefix: "g"
readability-identifier-naming.ConstexprFunctionCase: camelBack
readability-identifier-naming.ConstexprMethodCase: camelBack
readability-identifier-naming.ClassMethodCase: camelBack
readability-identifier-naming.ClassMemberCase: camelBack
readability-identifier-naming.ClassConstantCase: UPPER_CASE
readability-identifier-naming.ClassConstantPrefix: "k"
readability-identifier-naming.StaticConstantCase: UPPER_CASE
readability-identifier-naming.StaticConstantPrefix: "k"
readability-identifier-naming.StaticVariableCase: UPPER_CASE
readability-identifier-naming.StaticVariablePrefix: "k"
readability-identifier-naming.ConstexprVariableCase: UPPER_CASE
readability-identifier-naming.ConstexprVariablePrefix: "k"
readability-identifier-naming.LocalConstantCase: camelBack
readability-identifier-naming.LocalVariableCase: camelBack
readability-identifier-naming.TemplateParameterCase: CamelCase
readability-identifier-naming.ParameterCase: camelBack
readability-identifier-naming.FunctionCase: camelBack
readability-identifier-naming.MemberCase: camelBack
readability-identifier-naming.PrivateMemberSuffix: _
readability-identifier-naming.ProtectedMemberSuffix: _
readability-identifier-naming.PublicMemberSuffix: ""
readability-identifier-naming.GlobalFunctionIgnoredRegexp: "^(to_string|hash_append|tuple_hash)$"
bugprone-unsafe-functions.ReportMoreUnsafeFunctions: true
bugprone-unused-return-value.CheckedReturnTypes: ::std::error_code;::std::error_condition;::std::errc
misc-include-cleaner.IgnoreHeaders: ".*/(detail|impl)/.*;.*fwd\\.h(pp)?;time.h;stdlib.h;sqlite3.h;netinet/in\\.h;sys/resource\\.h;sys/sysinfo\\.h;linux/sysinfo\\.h;__chrono/.*;bits/.*;_abort\\.h;boost/uuid/uuid_hash.hpp;boost/beast/core/flat_buffer\\.hpp;boost/beast/http/field\\.hpp;boost/beast/http/dynamic_body\\.hpp;boost/beast/http/message\\.hpp;boost/beast/http/read\\.hpp;boost/beast/http/write\\.hpp;openssl/obj_mac\\.h"
#
HeaderFilterRegex: '^.*/(test|xrpl|xrpld)/.*\.(h|hpp)$'
HeaderFilterRegex: '^.*/(test|xrpl|xrpld)/.*\.(h|hpp|ipp)$'
ExcludeHeaderFilterRegex: '^.*/protocol_autogen/.*\.(h|hpp)$'
WarningsAsErrors: "*"

View File

@@ -133,7 +133,7 @@ public:
/// Returns a value if present, else another value.
template <class T>
[[nodiscard]] T
value_or(std::string const& name, T const& other) const
valueOr(std::string const& name, T const& other) const
{
auto const v = get<T>(name);
return v.has_value() ? *v : other;
@@ -142,7 +142,7 @@ public:
// indicates if trailing comments were seen
// during the appending of any lines/values
[[nodiscard]] bool
had_trailing_comments() const
hadTrailingComments() const
{
return had_trailing_comments_;
}
@@ -273,7 +273,7 @@ public:
// indicates if trailing comments were seen
// in any loaded Sections
[[nodiscard]] bool
had_trailing_comments() const
hadTrailingComments() const
{
return std::ranges::any_of(map_, [](auto s) { return s.second.had_trailing_comments(); });
}
@@ -294,17 +294,17 @@ template <class T>
bool
set(T& target, std::string const& name, Section const& section)
{
bool found_and_valid = false;
bool foundAndValid = false;
try
{
auto const val = section.get<T>(name);
if ((found_and_valid = val.has_value()))
if ((foundAndValid = val.has_value()))
target = *val;
}
catch (boost::bad_lexical_cast const&) // NOLINT(bugprone-empty-catch)
{
}
return found_and_valid;
return foundAndValid;
}
/** Set a value from a configuration Section
@@ -316,10 +316,10 @@ template <class T>
bool
set(T& target, T const& defaultValue, std::string const& name, Section const& section)
{
bool const found_and_valid = set<T>(target, name, section);
if (!found_and_valid)
bool const foundAndValid = set<T>(target, name, section);
if (!foundAndValid)
target = defaultValue;
return found_and_valid;
return foundAndValid;
}
/** Retrieve a key/value pair from a section.

View File

@@ -38,11 +38,11 @@ public:
do
{
head = instance.m_head.load();
head = instance.m_head_.load();
next_ = head;
} while (instance.m_head.exchange(this) != head);
} while (instance.m_head_.exchange(this) != head);
++instance.m_count;
++instance.m_count_;
}
~Counter() noexcept = default;
@@ -88,8 +88,8 @@ private:
~CountedObjects() noexcept = default;
private:
std::atomic<int> m_count;
std::atomic<Counter*> m_head;
std::atomic<int> m_count_;
std::atomic<Counter*> m_head_;
};
//------------------------------------------------------------------------------
@@ -108,8 +108,8 @@ private:
static auto&
getCounter() noexcept
{
static CountedObjects::Counter c{beast::type_name<Object>()};
return c;
static CountedObjects::Counter kC{beast::type_name<Object>()};
return kC;
}
CountedObject() noexcept

View File

@@ -16,9 +16,9 @@ namespace xrpl {
*/
// Exception thrown by an invalid access to Expected.
struct bad_expected_access : public std::runtime_error
struct BadExpectedAccess : public std::runtime_error
{
bad_expected_access() : runtime_error("bad expected access")
BadExpectedAccess() : runtime_error("bad expected access")
{
}
};
@@ -26,30 +26,30 @@ struct bad_expected_access : public std::runtime_error
namespace detail {
// Custom policy for Expected. Always throw on an invalid access.
struct throw_policy : public boost::outcome_v2::policy::base
struct ThrowPolicy : public boost::outcome_v2::policy::base
{
template <class Impl>
static constexpr void
wide_value_check(Impl&& self)
wideValueCheck(Impl&& self)
{
if (!base::_has_value(std::forward<Impl>(self)))
Throw<bad_expected_access>();
Throw<BadExpectedAccess>();
}
template <class Impl>
static constexpr void
wide_error_check(Impl&& self)
wideErrorCheck(Impl&& self)
{
if (!base::_has_error(std::forward<Impl>(self)))
Throw<bad_expected_access>();
Throw<BadExpectedAccess>();
}
template <class Impl>
static constexpr void
wide_exception_check(Impl&& self)
wideExceptionCheck(Impl&& self)
{
if (!base::_has_exception(std::forward<Impl>(self)))
Throw<bad_expected_access>();
Throw<BadExpectedAccess>();
}
};
@@ -107,9 +107,9 @@ Unexpected(E (&)[N]) -> Unexpected<E const*>;
// Definition of Expected. All of the machinery comes from boost::result.
template <class T, class E>
class [[nodiscard]] Expected : private boost::outcome_v2::result<T, E, detail::throw_policy>
class [[nodiscard]] Expected : private boost::outcome_v2::result<T, E, detail::ThrowPolicy>
{
using Base = boost::outcome_v2::result<T, E, detail::throw_policy>;
using Base = boost::outcome_v2::result<T, E, detail::ThrowPolicy>;
public:
template <typename U>
@@ -126,7 +126,7 @@ public:
}
[[nodiscard]] constexpr bool
has_value() const
hasValue() const
{
return Base::has_value();
}
@@ -158,7 +158,7 @@ public:
constexpr explicit
operator bool() const
{
return has_value();
return hasValue();
}
// Add operator* and operator-> so the Expected API looks a bit more like
@@ -193,9 +193,9 @@ public:
// (without a value) or the reason for the failure.
template <class E>
class [[nodiscard]]
Expected<void, E> : private boost::outcome_v2::result<void, E, detail::throw_policy>
Expected<void, E> : private boost::outcome_v2::result<void, E, detail::ThrowPolicy>
{
using Base = boost::outcome_v2::result<void, E, detail::throw_policy>;
using Base = boost::outcome_v2::result<void, E, detail::ThrowPolicy>;
public:
// The default constructor makes a successful Expected<void, E>.

View File

@@ -164,7 +164,7 @@ public:
/** Return the strong count */
[[nodiscard]] std::size_t
use_count() const;
useCount() const;
template <class TT, class... Args>
friend SharedIntrusive<TT>
@@ -364,7 +364,7 @@ public:
* return 0
*/
[[nodiscard]] std::size_t
use_count() const;
useCount() const;
/** Return true if there is a non-zero strong count. */
[[nodiscard]] bool
@@ -406,8 +406,8 @@ private:
// pointer. The low bit must be masked to zero when converting back to a
// pointer. If the low bit is '1', this is a weak pointer.
std::uintptr_t tp_{0};
static constexpr std::uintptr_t tagMask = 1;
static constexpr std::uintptr_t ptrMask = ~tagMask;
static constexpr std::uintptr_t kTAG_MASK = 1;
static constexpr std::uintptr_t kPTR_MASK = ~kTAG_MASK;
private:
/** Return the raw pointer held by this object.
@@ -415,7 +415,7 @@ private:
[[nodiscard]] T*
unsafeGetRawPtr() const;
enum class RefStrength { strong, weak };
enum class RefStrength { Strong, Weak };
/** Set the raw pointer and tag bit directly.
*/
void

View File

@@ -226,7 +226,7 @@ SharedIntrusive<T>::get() const
template <class T>
std::size_t
SharedIntrusive<T>::use_count() const
SharedIntrusive<T>::useCount() const
{
if (auto p = unsafeGetRawPtr())
return p->use_count();
@@ -266,12 +266,12 @@ SharedIntrusive<T>::unsafeReleaseAndStore(T* next)
auto action = prev->releaseStrongRef();
switch (action)
{
case noop:
case Noop:
break;
case destroy:
case Destroy:
delete prev;
break;
case partialDestroy:
case PartialDestroy:
prev->partialDestructor();
partialDestructorFinished(&prev);
// prev is null and may no longer be used
@@ -367,9 +367,9 @@ WeakIntrusive<T>::unsafeReleaseNoStore()
auto action = ptr_->releaseWeakRef();
switch (action)
{
case noop:
case Noop:
break;
case destroy:
case Destroy:
delete ptr_;
break;
}
@@ -517,7 +517,7 @@ SharedWeakUnion<T>::get() const
template <class T>
std::size_t
SharedWeakUnion<T>::use_count() const
SharedWeakUnion<T>::useCount() const
{
if (auto p = get())
return p->use_count();
@@ -559,14 +559,14 @@ template <class T>
bool
SharedWeakUnion<T>::isStrong() const
{
return !(tp_ & tagMask);
return !(tp_ & kTAG_MASK);
}
template <class T>
bool
SharedWeakUnion<T>::isWeak() const
{
return tp_ & tagMask;
return tp_ & kTAG_MASK;
}
template <class T>
@@ -581,7 +581,7 @@ SharedWeakUnion<T>::convertToStrong()
{
[[maybe_unused]] auto action = p->releaseWeakRef();
XRPL_ASSERT(
(action == ReleaseWeakRefAction::noop),
(action == ReleaseWeakRefAction::Noop),
"xrpl::SharedWeakUnion::convertToStrong : "
"action is noop");
unsafeSetRawPtr(p, RefStrength::strong);
@@ -605,9 +605,9 @@ SharedWeakUnion<T>::convertToWeak()
auto action = p->addWeakReleaseStrongRef();
switch (action)
{
case noop:
case Noop:
break;
case destroy:
case Destroy:
// We just added a weak ref. How could we destroy?
// LCOV_EXCL_START
UNREACHABLE(
@@ -617,7 +617,7 @@ SharedWeakUnion<T>::convertToWeak()
unsafeSetRawPtr(nullptr);
return true; // Should never happen
// LCOV_EXCL_STOP
case partialDestroy:
case PartialDestroy:
// This is a weird case. We just converted the last strong
// pointer to a weak pointer.
p->partialDestructor();
@@ -633,7 +633,7 @@ template <class T>
T*
SharedWeakUnion<T>::unsafeGetRawPtr() const
{
return reinterpret_cast<T*>(tp_ & ptrMask);
return reinterpret_cast<T*>(tp_ & kPTR_MASK);
}
template <class T>
@@ -642,7 +642,7 @@ SharedWeakUnion<T>::unsafeSetRawPtr(T* p, RefStrength rs)
{
tp_ = reinterpret_cast<std::uintptr_t>(p);
if (tp_ && rs == RefStrength::weak)
tp_ |= tagMask;
tp_ |= kTAG_MASK;
}
template <class T>
@@ -666,12 +666,12 @@ SharedWeakUnion<T>::unsafeReleaseNoStore()
auto strongAction = p->releaseStrongRef();
switch (strongAction)
{
case noop:
case Noop:
break;
case destroy:
case Destroy:
delete p;
break;
case partialDestroy:
case PartialDestroy:
p->partialDestructor();
partialDestructorFinished(&p);
// p is null and may no longer be used
@@ -684,9 +684,9 @@ SharedWeakUnion<T>::unsafeReleaseNoStore()
auto weakAction = p->releaseWeakRef();
switch (weakAction)
{
case noop:
case Noop:
break;
case destroy:
case Destroy:
delete p;
break;
}

View File

@@ -18,7 +18,7 @@ namespace xrpl {
destroy: Run the destructor. This action will occur when either the strong
count or weak count is decremented and the other count is also zero.
*/
enum class ReleaseStrongRefAction { noop, partialDestroy, destroy };
enum class ReleaseStrongRefAction { Noop, PartialDestroy, Destroy };
/** Action to perform when releasing a weak pointer.
@@ -28,7 +28,7 @@ enum class ReleaseStrongRefAction { noop, partialDestroy, destroy };
destroy: Run the destructor. This action will occur when either the strong
count or weak count is decremented and the other count is also zero.
*/
enum class ReleaseWeakRefAction { noop, destroy };
enum class ReleaseWeakRefAction { Noop, Destroy };
/** Implement the strong count, weak count, and bit flags for an intrusive
pointer.
@@ -71,7 +71,7 @@ struct IntrusiveRefCounts
expired() const noexcept;
std::size_t
use_count() const noexcept;
useCount() const noexcept;
// This function MUST be called after a partial destructor finishes running.
// Calling this function may cause other threads to delete the object
@@ -98,11 +98,11 @@ private:
// enough for strong pointers and 14 bit counts are enough for weak
// pointers. Use type aliases to make it easy to switch types.
using CountType = std::uint16_t;
static constexpr size_t StrongCountNumBits = sizeof(CountType) * 8;
static constexpr size_t WeakCountNumBits = StrongCountNumBits - 2;
static constexpr size_t kSTRONG_COUNT_NUM_BITS = sizeof(CountType) * 8;
static constexpr size_t kWEAK_COUNT_NUM_BITS = kSTRONG_COUNT_NUM_BITS - 2;
using FieldType = std::uint32_t;
static constexpr size_t FieldTypeBits = sizeof(FieldType) * 8;
static constexpr FieldType one = 1;
static constexpr size_t kFIELD_TYPE_BITS = sizeof(FieldType) * 8;
static constexpr FieldType kONE = 1;
/** `refCounts` consists of four fields that are treated atomically:
@@ -137,21 +137,21 @@ private:
*/
mutable std::atomic<FieldType> refCounts{strongDelta};
mutable std::atomic<FieldType> refCounts_{kSTRONG_DELTA};
/** Amount to change the strong count when adding or releasing a reference
Note: The strong count is stored in the low `StrongCountNumBits` bits
of refCounts
*/
static constexpr FieldType strongDelta = 1;
static constexpr FieldType kSTRONG_DELTA = 1;
/** Amount to change the weak count when adding or releasing a reference
Note: The weak count is stored in the high `WeakCountNumBits` bits of
refCounts
*/
static constexpr FieldType weakDelta = (one << StrongCountNumBits);
static constexpr FieldType kWEAK_DELTA = (kONE << kSTRONG_COUNT_NUM_BITS);
/** Flag that is set when the partialDestroy function has started running
(or is about to start running).
@@ -159,33 +159,34 @@ private:
See description of the `refCounts` field for a fuller description of
this field.
*/
static constexpr FieldType partialDestroyStartedMask = (one << (FieldTypeBits - 1));
static constexpr FieldType kPARTIAL_DESTROY_STARTED_MASK = (kONE << (kFIELD_TYPE_BITS - 1));
/** Flag that is set when the partialDestroy function has finished running
See description of the `refCounts` field for a fuller description of
this field.
*/
static constexpr FieldType partialDestroyFinishedMask = (one << (FieldTypeBits - 2));
static constexpr FieldType kPARTIAL_DESTROY_FINISHED_MASK = (kONE << (kFIELD_TYPE_BITS - 2));
/** Mask that will zero out all the `count` bits and leave the tag bits
unchanged.
*/
static constexpr FieldType tagMask = partialDestroyStartedMask | partialDestroyFinishedMask;
static constexpr FieldType kTAG_MASK =
kPARTIAL_DESTROY_STARTED_MASK | kPARTIAL_DESTROY_FINISHED_MASK;
/** Mask that will zero out the `tag` bits and leave the count bits
unchanged.
*/
static constexpr FieldType valueMask = ~tagMask;
static constexpr FieldType kVALUE_MASK = ~kTAG_MASK;
/** Mask that will zero out everything except the strong count.
*/
static constexpr FieldType strongMask = ((one << StrongCountNumBits) - 1) & valueMask;
static constexpr FieldType kSTRONG_MASK = ((kONE << kSTRONG_COUNT_NUM_BITS) - 1) & kVALUE_MASK;
/** Mask that will zero out everything except the weak count.
*/
static constexpr FieldType weakMask =
(((one << WeakCountNumBits) - 1) << StrongCountNumBits) & valueMask;
static constexpr FieldType kWEAK_MASK =
(((kONE << kWEAK_COUNT_NUM_BITS) - 1) << kSTRONG_COUNT_NUM_BITS) & kVALUE_MASK;
/** Unpack the count and tag fields from the packed atomic integer form. */
struct RefCountPair
@@ -210,29 +211,29 @@ private:
[[nodiscard]] FieldType
combinedValue() const noexcept;
static constexpr CountType maxStrongValue =
static_cast<CountType>((one << StrongCountNumBits) - 1);
static constexpr CountType maxWeakValue =
static_cast<CountType>((one << WeakCountNumBits) - 1);
static constexpr CountType kMAX_STRONG_VALUE =
static_cast<CountType>((kONE << kSTRONG_COUNT_NUM_BITS) - 1);
static constexpr CountType kMAX_WEAK_VALUE =
static_cast<CountType>((kONE << kWEAK_COUNT_NUM_BITS) - 1);
/** Put an extra margin to detect when running up against limits.
This is only used in debug code, and is useful if we reduce the
number of bits in the strong and weak counts (to 16 and 14 bits).
*/
static constexpr CountType checkStrongMaxValue = maxStrongValue - 32;
static constexpr CountType checkWeakMaxValue = maxWeakValue - 32;
static constexpr CountType kCHECK_STRONG_MAX_VALUE = kMAX_STRONG_VALUE - 32;
static constexpr CountType kCHECK_WEAK_MAX_VALUE = kMAX_WEAK_VALUE - 32;
};
};
inline void
IntrusiveRefCounts::addStrongRef() const noexcept
{
refCounts.fetch_add(strongDelta, std::memory_order_acq_rel);
refCounts_.fetch_add(kSTRONG_DELTA, std::memory_order_acq_rel);
}
inline void
IntrusiveRefCounts::addWeakRef() const noexcept
{
refCounts.fetch_add(weakDelta, std::memory_order_acq_rel);
refCounts_.fetch_add(kWEAK_DELTA, std::memory_order_acq_rel);
}
inline ReleaseStrongRefAction
@@ -246,36 +247,36 @@ IntrusiveRefCounts::releaseStrongRef() const
// conditional `fetch_or`. This loop will almost always run once.
using enum ReleaseStrongRefAction;
auto prevIntVal = refCounts.load(std::memory_order_acquire);
auto prevIntVal = refCounts_.load(std::memory_order_acquire);
while (true)
{
RefCountPair const prevVal{prevIntVal};
XRPL_ASSERT(
(prevVal.strong >= strongDelta),
(prevVal.strong >= kSTRONG_DELTA),
"xrpl::IntrusiveRefCounts::releaseStrongRef : previous ref "
"higher than new");
auto nextIntVal = prevIntVal - strongDelta;
ReleaseStrongRefAction action = noop;
auto nextIntVal = prevIntVal - kSTRONG_DELTA;
ReleaseStrongRefAction action = Noop;
if (prevVal.strong == 1)
{
if (prevVal.weak == 0)
{
action = destroy;
action = Destroy;
}
else
{
nextIntVal |= partialDestroyStartedMask;
action = partialDestroy;
nextIntVal |= kPARTIAL_DESTROY_STARTED_MASK;
action = PartialDestroy;
}
}
if (refCounts.compare_exchange_weak(prevIntVal, nextIntVal, std::memory_order_acq_rel))
if (refCounts_.compare_exchange_weak(prevIntVal, nextIntVal, std::memory_order_acq_rel))
{
// Can't be in partial destroy because only decrementing the strong
// count to zero can start a partial destroy, and that can't happen
// twice.
XRPL_ASSERT(
(action == noop) || !(prevIntVal & partialDestroyStartedMask),
(action == Noop) || !(prevIntVal & kPARTIAL_DESTROY_STARTED_MASK),
"xrpl::IntrusiveRefCounts::releaseStrongRef : not in partial "
"destroy");
return action;
@@ -288,9 +289,9 @@ IntrusiveRefCounts::addWeakReleaseStrongRef() const
{
using enum ReleaseStrongRefAction;
static_assert(weakDelta > strongDelta);
auto constexpr delta = weakDelta - strongDelta;
auto prevIntVal = refCounts.load(std::memory_order_acquire);
static_assert(kWEAK_DELTA > kSTRONG_DELTA);
auto constexpr kDELTA = kWEAK_DELTA - kSTRONG_DELTA;
auto prevIntVal = refCounts_.load(std::memory_order_acquire);
// This loop will almost always run once. The loop is needed to atomically
// change the counts and flags (the count could be atomically changed, but
// the flags depend on the current value of the counts).
@@ -311,24 +312,24 @@ IntrusiveRefCounts::addWeakReleaseStrongRef() const
"xrpl::IntrusiveRefCounts::addWeakReleaseStrongRef : not in "
"partial destroy");
auto nextIntVal = prevIntVal + delta;
ReleaseStrongRefAction action = noop;
auto nextIntVal = prevIntVal + kDELTA;
ReleaseStrongRefAction action = Noop;
if (prevVal.strong == 1)
{
if (prevVal.weak == 0)
{
action = noop;
action = Noop;
}
else
{
nextIntVal |= partialDestroyStartedMask;
action = partialDestroy;
nextIntVal |= kPARTIAL_DESTROY_STARTED_MASK;
action = PartialDestroy;
}
}
if (refCounts.compare_exchange_weak(prevIntVal, nextIntVal, std::memory_order_acq_rel))
if (refCounts_.compare_exchange_weak(prevIntVal, nextIntVal, std::memory_order_acq_rel))
{
XRPL_ASSERT(
(!(prevIntVal & partialDestroyStartedMask)),
(!(prevIntVal & kPARTIAL_DESTROY_STARTED_MASK)),
"xrpl::IntrusiveRefCounts::addWeakReleaseStrongRef : not "
"started partial destroy");
return action;
@@ -339,7 +340,7 @@ IntrusiveRefCounts::addWeakReleaseStrongRef() const
inline ReleaseWeakRefAction
IntrusiveRefCounts::releaseWeakRef() const
{
auto prevIntVal = refCounts.fetch_sub(weakDelta, std::memory_order_acq_rel);
auto prevIntVal = refCounts_.fetch_sub(kWEAK_DELTA, std::memory_order_acq_rel);
RefCountPair prev = prevIntVal;
if (prev.weak == 1 && prev.strong == 0)
{
@@ -348,19 +349,19 @@ IntrusiveRefCounts::releaseWeakRef() const
// This case should only be hit if the partialDestroyStartedBit is
// set non-atomically (and even then very rarely). The code is kept
// in case we need to set the flag non-atomically for perf reasons.
refCounts.wait(prevIntVal, std::memory_order_acquire);
prevIntVal = refCounts.load(std::memory_order_acquire);
refCounts_.wait(prevIntVal, std::memory_order_acquire);
prevIntVal = refCounts_.load(std::memory_order_acquire);
prev = RefCountPair{prevIntVal};
}
if (prev.partialDestroyFinishedBit == 0u)
{
// partial destroy MUST finish before running a full destroy (when
// using weak pointers)
refCounts.wait(prevIntVal - weakDelta, std::memory_order_acquire);
refCounts_.wait(prevIntVal - kWEAK_DELTA, std::memory_order_acquire);
}
return ReleaseWeakRefAction::destroy;
return ReleaseWeakRefAction::Destroy;
}
return ReleaseWeakRefAction::noop;
return ReleaseWeakRefAction::Noop;
}
inline bool
@@ -369,13 +370,13 @@ IntrusiveRefCounts::checkoutStrongRefFromWeak() const noexcept
auto curValue = RefCountPair{1, 1}.combinedValue();
auto desiredValue = RefCountPair{2, 1}.combinedValue();
while (!refCounts.compare_exchange_weak(curValue, desiredValue, std::memory_order_acq_rel))
while (!refCounts_.compare_exchange_weak(curValue, desiredValue, std::memory_order_acq_rel))
{
RefCountPair const prev{curValue};
if (prev.strong == 0u)
return false;
desiredValue = curValue + strongDelta;
desiredValue = curValue + kSTRONG_DELTA;
}
return true;
}
@@ -383,38 +384,39 @@ IntrusiveRefCounts::checkoutStrongRefFromWeak() const noexcept
inline bool
IntrusiveRefCounts::expired() const noexcept
{
RefCountPair const val = refCounts.load(std::memory_order_acquire);
RefCountPair const val = refCounts_.load(std::memory_order_acquire);
return val.strong == 0;
}
inline std::size_t
IntrusiveRefCounts::use_count() const noexcept
IntrusiveRefCounts::useCount() const noexcept
{
RefCountPair const val = refCounts.load(std::memory_order_acquire);
RefCountPair const val = refCounts_.load(std::memory_order_acquire);
return val.strong;
}
inline IntrusiveRefCounts::~IntrusiveRefCounts() noexcept
{
#ifndef NDEBUG
auto v = refCounts.load(std::memory_order_acquire);
auto v = refCounts_.load(std::memory_order_acquire);
XRPL_ASSERT(
(!(v & valueMask)), "xrpl::IntrusiveRefCounts::~IntrusiveRefCounts : count must be zero");
auto t = v & tagMask;
XRPL_ASSERT((!t || t == tagMask), "xrpl::IntrusiveRefCounts::~IntrusiveRefCounts : valid tag");
(!(v & kVALUE_MASK)), "xrpl::IntrusiveRefCounts::~IntrusiveRefCounts : count must be zero");
auto t = v & kTAG_MASK;
XRPL_ASSERT(
(!t || t == kTAG_MASK), "xrpl::IntrusiveRefCounts::~IntrusiveRefCounts : valid tag");
#endif
}
//------------------------------------------------------------------------------
inline IntrusiveRefCounts::RefCountPair::RefCountPair(IntrusiveRefCounts::FieldType v) noexcept
: strong{static_cast<CountType>(v & strongMask)}
, weak{static_cast<CountType>((v & weakMask) >> StrongCountNumBits)}
, partialDestroyStartedBit{v & partialDestroyStartedMask}
, partialDestroyFinishedBit{v & partialDestroyFinishedMask}
: strong{static_cast<CountType>(v & kSTRONG_MASK)}
, weak{static_cast<CountType>((v & kWEAK_MASK) >> kSTRONG_COUNT_NUM_BITS)}
, partialDestroyStartedBit{v & kPARTIAL_DESTROY_STARTED_MASK}
, partialDestroyFinishedBit{v & kPARTIAL_DESTROY_FINISHED_MASK}
{
XRPL_ASSERT(
(strong < checkStrongMaxValue && weak < checkWeakMaxValue),
(strong < kCHECK_STRONG_MAX_VALUE && weak < kCHECK_WEAK_MAX_VALUE),
"xrpl::IntrusiveRefCounts::RefCountPair(FieldType) : inputs inside "
"range");
}
@@ -425,7 +427,7 @@ inline IntrusiveRefCounts::RefCountPair::RefCountPair(
: strong{s}, weak{w}
{
XRPL_ASSERT(
(strong < checkStrongMaxValue && weak < checkWeakMaxValue),
(strong < kCHECK_STRONG_MAX_VALUE && weak < kCHECK_WEAK_MAX_VALUE),
"xrpl::IntrusiveRefCounts::RefCountPair(CountType, CountType) : "
"inputs inside range");
}
@@ -434,11 +436,11 @@ inline IntrusiveRefCounts::FieldType
IntrusiveRefCounts::RefCountPair::combinedValue() const noexcept
{
XRPL_ASSERT(
(strong < checkStrongMaxValue && weak < checkWeakMaxValue),
(strong < kCHECK_STRONG_MAX_VALUE && weak < kCHECK_WEAK_MAX_VALUE),
"xrpl::IntrusiveRefCounts::RefCountPair::combinedValue : inputs "
"inside range");
return (static_cast<IntrusiveRefCounts::FieldType>(weak)
<< IntrusiveRefCounts::StrongCountNumBits) |
<< IntrusiveRefCounts::kSTRONG_COUNT_NUM_BITS) |
static_cast<IntrusiveRefCounts::FieldType>(strong) | partialDestroyStartedBit |
partialDestroyFinishedBit;
}
@@ -449,7 +451,7 @@ partialDestructorFinished(T** o)
{
T& self = **o;
IntrusiveRefCounts::RefCountPair const p =
self.refCounts.fetch_or(IntrusiveRefCounts::partialDestroyFinishedMask);
self.refCounts_.fetch_or(IntrusiveRefCounts::kPARTIAL_DESTROY_FINISHED_MASK);
XRPL_ASSERT(
(!p.partialDestroyFinishedBit && p.partialDestroyStartedBit && !p.strong),
"xrpl::partialDestructorFinished : not a weak ref");
@@ -458,7 +460,7 @@ partialDestructorFinished(T** o)
// There was a weak count before the partial destructor ran (or we would
// have run the full destructor) and now there isn't a weak count. Some
// thread is waiting to run the destructor.
self.refCounts.notify_one();
self.refCounts_.notify_one();
}
// Set the pointer to null to emphasize that the object shouldn't be used
// after calling this function as it may be destroyed in another thread.

View File

@@ -26,17 +26,17 @@ struct LocalValues
template <class T>
struct Value : BasicValue
{
T t_;
T t;
Value() = default;
explicit Value(T t) : t_(std::move(t))
explicit Value(T t) : t(std::move(t))
{
}
void*
get() override
{
return &t_;
return &t;
}
};
@@ -55,8 +55,8 @@ template <class = void>
boost::thread_specific_ptr<detail::LocalValues>&
getLocalValues()
{
static boost::thread_specific_ptr<detail::LocalValues> tsp(&detail::LocalValues::cleanup);
return tsp;
static boost::thread_specific_ptr<detail::LocalValues> kTSP(&detail::LocalValues::cleanup);
return kTSP;
}
} // namespace detail

View File

@@ -17,15 +17,15 @@ namespace xrpl {
// DEPRECATED use beast::severities::Severity instead
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
enum LogSeverity {
lsINVALID = -1, // used to indicate an invalid severity
lsTRACE = 0, // Very low-level progress information, details inside
LsInvalid = -1, // used to indicate an invalid severity
LsTrace = 0, // Very low-level progress information, details inside
// an operation
lsDEBUG = 1, // Function-level progress information, operations
lsINFO = 2, // Server-level progress information, major operations
lsWARNING = 3, // Conditions that warrant human attention, may indicate
LsDebug = 1, // Function-level progress information, operations
LsInfo = 2, // Server-level progress information, major operations
LsWarning = 3, // Conditions that warrant human attention, may indicate
// a problem
lsERROR = 4, // A condition that indicates a problem
lsFATAL = 5 // A severe condition that indicates a server problem
LsError = 4, // A condition that indicates a problem
LsFatal = 5 // A severe condition that indicates a server problem
};
/** Manages partitions for logging. */
@@ -130,8 +130,8 @@ private:
/** @} */
private:
std::unique_ptr<std::ofstream> m_stream;
boost::filesystem::path m_path;
std::unique_ptr<std::ofstream> m_stream_;
boost::filesystem::path m_path_;
};
std::mutex mutable mutex_;
@@ -168,7 +168,7 @@ public:
threshold(beast::severities::Severity thresh);
std::vector<std::pair<std::string, std::string>>
partition_severities() const;
partitionSeverities() const;
void
write(
@@ -214,7 +214,7 @@ private:
// Maximum line length for log messages.
// If the message exceeds this length it will be truncated with
// ellipses.
maximumMessageCharacters = 12 * 1024
MaximumMessageCharacters = 12 * 1024
};
static void

View File

@@ -70,27 +70,27 @@ isPowerOfTen(T value)
struct MantissaRange
{
using rep = std::uint64_t;
enum class mantissa_scale { small, large };
enum class MantissaScale { Small, Large };
explicit constexpr MantissaRange(mantissa_scale scale_)
: min(getMin(scale_)), log(logTen(min).value_or(-1)), scale(scale_)
explicit constexpr MantissaRange(MantissaScale scale)
: min(getMin(scale)), log(logTen(min).value_or(-1)), scale(scale)
{
}
rep min;
rep max{(min * 10) - 1};
int log;
mantissa_scale scale;
MantissaScale scale;
private:
static constexpr rep
getMin(mantissa_scale scale_)
getMin(MantissaScale scale)
{
switch (scale_)
switch (scale)
{
case mantissa_scale::small:
case MantissaScale::Small:
return 1'000'000'000'000'000ULL;
case mantissa_scale::large:
case MantissaScale::Large:
return 1'000'000'000'000'000'000ULL;
default:
// Since this can never be called outside a non-constexpr
@@ -214,26 +214,26 @@ class Number
public:
// The range for the exponent when normalized
constexpr static int minExponent = -32768;
constexpr static int maxExponent = 32768;
constexpr static int kMIN_EXPONENT = -32768;
constexpr static int kMAX_EXPONENT = 32768;
constexpr static internalrep maxRep = std::numeric_limits<rep>::max();
static_assert(maxRep == 9'223'372'036'854'775'807);
static_assert(-maxRep == std::numeric_limits<rep>::min() + 1);
constexpr static internalrep kMAX_REP = std::numeric_limits<rep>::max();
static_assert(kMAX_REP == 9'223'372'036'854'775'807);
static_assert(-kMAX_REP == std::numeric_limits<rep>::min() + 1);
// May need to make unchecked private
struct unchecked
struct Unchecked
{
explicit unchecked() = default;
explicit Unchecked() = default;
};
// Like unchecked, normalized is used with the ctors that take an
// internalrep mantissa. Unlike unchecked, those ctors will normalize the
// value.
// Only unit tests are expected to use this class
struct normalized
struct Normalized
{
explicit normalized() = default;
explicit Normalized() = default;
};
explicit constexpr Number() = default;
@@ -244,13 +244,13 @@ public:
bool negative,
internalrep mantissa,
int exponent,
unchecked) noexcept;
Unchecked) noexcept;
// Assume unsigned values are... unsigned. i.e. positive
explicit constexpr Number(internalrep mantissa, int exponent, unchecked) noexcept;
explicit constexpr Number(internalrep mantissa, int exponent, Unchecked) noexcept;
// Only unit tests are expected to use this ctor
explicit Number(bool negative, internalrep mantissa, int exponent, normalized);
explicit Number(bool negative, internalrep mantissa, int exponent, Normalized);
// Assume unsigned values are... unsigned. i.e. positive
explicit Number(internalrep mantissa, int exponent, normalized);
explicit Number(internalrep mantissa, int exponent, Normalized);
[[nodiscard]] constexpr rep
mantissa() const noexcept;
@@ -384,42 +384,42 @@ public:
root2(Number f);
// Thread local rounding control. Default is to_nearest
enum class rounding_mode { to_nearest, towards_zero, downward, upward };
static rounding_mode
enum class RoundingMode { ToNearest, TowardsZero, Downward, Upward };
static RoundingMode
getround();
// Returns previously set mode
static rounding_mode
setround(rounding_mode mode);
static RoundingMode
setround(RoundingMode mode);
/** Returns which mantissa scale is currently in use for normalization.
*
* If you think you need to call this outside of unit tests, no you don't.
*/
static MantissaRange::mantissa_scale
static MantissaRange::MantissaScale
getMantissaScale();
/** Changes which mantissa scale is used for normalization.
*
* If you think you need to call this outside of unit tests, no you don't.
*/
static void
setMantissaScale(MantissaRange::mantissa_scale scale);
setMantissaScale(MantissaRange::MantissaScale scale);
static internalrep
minMantissa()
{
return range_.get().min;
return range.get().min;
}
static internalrep
maxMantissa()
{
return range_.get().max;
return range.get().max;
}
static int
mantissaLog()
{
return range_.get().log;
return range.get().log;
}
/// oneSmall is needed because the ranges are private
@@ -440,28 +440,28 @@ public:
normalizeToRange(T minMantissa, T maxMantissa) const;
private:
static thread_local rounding_mode mode_;
static thread_local RoundingMode mode;
// The available ranges for mantissa
constexpr static MantissaRange smallRange{MantissaRange::mantissa_scale::small};
static_assert(isPowerOfTen(smallRange.min));
static_assert(smallRange.min == 1'000'000'000'000'000LL);
static_assert(smallRange.max == 9'999'999'999'999'999LL);
static_assert(smallRange.log == 15);
static_assert(smallRange.min < maxRep);
static_assert(smallRange.max < maxRep);
constexpr static MantissaRange largeRange{MantissaRange::mantissa_scale::large};
static_assert(isPowerOfTen(largeRange.min));
static_assert(largeRange.min == 1'000'000'000'000'000'000ULL);
static_assert(largeRange.max == internalrep(9'999'999'999'999'999'999ULL));
static_assert(largeRange.log == 18);
static_assert(largeRange.min < maxRep);
static_assert(largeRange.max > maxRep);
constexpr static MantissaRange kSMALL_RANGE{MantissaRange::MantissaScale::Small};
static_assert(isPowerOfTen(kSMALL_RANGE.min));
static_assert(kSMALL_RANGE.min == 1'000'000'000'000'000LL);
static_assert(kSMALL_RANGE.max == 9'999'999'999'999'999LL);
static_assert(kSMALL_RANGE.log == 15);
static_assert(kSMALL_RANGE.min < kMAX_REP);
static_assert(kSMALL_RANGE.max < kMAX_REP);
constexpr static MantissaRange kLARGE_RANGE{MantissaRange::MantissaScale::Large};
static_assert(isPowerOfTen(kLARGE_RANGE.min));
static_assert(kLARGE_RANGE.min == 1'000'000'000'000'000'000ULL);
static_assert(kLARGE_RANGE.max == internalrep(9'999'999'999'999'999'999ULL));
static_assert(kLARGE_RANGE.log == 18);
static_assert(kLARGE_RANGE.min < kMAX_REP);
static_assert(kLARGE_RANGE.max > kMAX_REP);
// The range for the mantissa when normalized.
// Use reference_wrapper to avoid making copies, and prevent accidentally
// changing the values inside the range.
static thread_local std::reference_wrapper<MantissaRange const> range_;
static thread_local std::reference_wrapper<MantissaRange const> range;
void
normalize();
@@ -485,8 +485,8 @@ private:
friend void
doNormalize(
bool& negative,
T& mantissa_,
int& exponent_,
T& mantissa,
int& exponent,
MantissaRange::rep const& minMantissa,
MantissaRange::rep const& maxMantissa);
@@ -509,31 +509,31 @@ private:
class Guard;
};
constexpr Number::Number(bool negative, internalrep mantissa, int exponent, unchecked) noexcept
constexpr Number::Number(bool negative, internalrep mantissa, int exponent, Unchecked) noexcept
: negative_(negative), mantissa_{mantissa}, exponent_{exponent}
{
}
constexpr Number::Number(internalrep mantissa, int exponent, unchecked) noexcept
: Number(false, mantissa, exponent, unchecked{})
constexpr Number::Number(internalrep mantissa, int exponent, Unchecked) noexcept
: Number(false, mantissa, exponent, Unchecked{})
{
}
constexpr static Number numZero{};
constexpr static Number kNUM_ZERO{};
inline Number::Number(bool negative, internalrep mantissa, int exponent, normalized)
: Number(negative, mantissa, exponent, unchecked{})
inline Number::Number(bool negative, internalrep mantissa, int exponent, Normalized)
: Number(negative, mantissa, exponent, Unchecked{})
{
normalize();
}
inline Number::Number(internalrep mantissa, int exponent, normalized)
: Number(false, mantissa, exponent, normalized{})
inline Number::Number(internalrep mantissa, int exponent, Normalized)
: Number(false, mantissa, exponent, Normalized{})
{
}
inline Number::Number(rep mantissa, int exponent)
: Number(mantissa < 0, externalToInternal(mantissa), exponent, normalized{})
: Number(mantissa < 0, externalToInternal(mantissa), exponent, Normalized{})
{
}
@@ -550,10 +550,10 @@ constexpr Number::rep
Number::mantissa() const noexcept
{
auto m = mantissa_;
if (m > maxRep)
if (m > kMAX_REP)
{
XRPL_ASSERT_PARTS(
!isnormal() || (m % 10 == 0 && m / 10 <= maxRep),
!isnormal() || (m % 10 == 0 && m / 10 <= kMAX_REP),
"xrpl::Number::mantissa",
"large normalized mantissa has no remainder");
m /= 10;
@@ -571,10 +571,10 @@ constexpr int
Number::exponent() const noexcept
{
auto e = exponent_;
if (mantissa_ > maxRep)
if (mantissa_ > kMAX_REP)
{
XRPL_ASSERT_PARTS(
!isnormal() || (mantissa_ % 10 == 0 && mantissa_ / 10 <= maxRep),
!isnormal() || (mantissa_ % 10 == 0 && mantissa_ / 10 <= kMAX_REP),
"xrpl::Number::exponent",
"large normalized mantissa has no remainder");
++e;
@@ -669,29 +669,29 @@ operator/(Number const& x, Number const& y)
inline Number
Number::min() noexcept
{
return Number{false, range_.get().min, minExponent, unchecked{}};
return Number{false, range.get().min, kMIN_EXPONENT, Unchecked{}};
}
inline Number
Number::max() noexcept
{
return Number{false, std::min(range_.get().max, maxRep), maxExponent, unchecked{}};
return Number{false, std::min(range.get().max, kMAX_REP), kMAX_EXPONENT, Unchecked{}};
}
inline Number
Number::lowest() noexcept
{
return Number{true, std::min(range_.get().max, maxRep), maxExponent, unchecked{}};
return Number{true, std::min(range.get().max, kMAX_REP), kMAX_EXPONENT, Unchecked{}};
}
inline bool
Number::isnormal() const noexcept
{
MantissaRange const& range = range_;
auto const abs_m = mantissa_;
MantissaRange const& range = range;
auto const absM = mantissa_;
return *this == Number{} ||
(range.min <= abs_m && abs_m <= range.max && (abs_m <= maxRep || abs_m % 10 == 0) &&
minExponent <= exponent_ && exponent_ <= maxExponent);
(range.min <= absM && absM <= range.max && (absM <= kMAX_REP || absM % 10 == 0) &&
kMIN_EXPONENT <= exponent_ && exponent_ <= kMAX_EXPONENT);
}
template <Integral64 T>
@@ -755,34 +755,34 @@ squelch(Number const& x, Number const& limit) noexcept
}
inline std::string
to_string(MantissaRange::mantissa_scale const& scale)
to_string(MantissaRange::MantissaScale const& scale)
{
switch (scale)
{
case MantissaRange::mantissa_scale::small:
case MantissaRange::MantissaScale::Small:
return "small";
case MantissaRange::mantissa_scale::large:
case MantissaRange::MantissaScale::Large:
return "large";
default:
throw std::runtime_error("Bad scale");
}
}
class saveNumberRoundMode
class SaveNumberRoundMode
{
Number::rounding_mode mode_;
Number::RoundingMode mode_;
public:
~saveNumberRoundMode()
~SaveNumberRoundMode()
{
Number::setround(mode_);
}
explicit saveNumberRoundMode(Number::rounding_mode mode) noexcept : mode_{mode}
explicit SaveNumberRoundMode(Number::RoundingMode mode) noexcept : mode_{mode}
{
}
saveNumberRoundMode(saveNumberRoundMode const&) = delete;
saveNumberRoundMode&
operator=(saveNumberRoundMode const&) = delete;
SaveNumberRoundMode(SaveNumberRoundMode const&) = delete;
SaveNumberRoundMode&
operator=(SaveNumberRoundMode const&) = delete;
};
// saveNumberRoundMode doesn't do quite enough for us. What we want is a
@@ -791,10 +791,10 @@ public:
// build it here.
class NumberRoundModeGuard
{
saveNumberRoundMode saved_;
SaveNumberRoundMode saved_;
public:
explicit NumberRoundModeGuard(Number::rounding_mode mode) noexcept
explicit NumberRoundModeGuard(Number::RoundingMode mode) noexcept
: saved_{Number::setround(mode)}
{
}
@@ -812,10 +812,10 @@ public:
*/
class NumberMantissaScaleGuard
{
MantissaRange::mantissa_scale const saved_;
MantissaRange::MantissaScale const saved_;
public:
explicit NumberMantissaScaleGuard(MantissaRange::mantissa_scale scale) noexcept
explicit NumberMantissaScaleGuard(MantissaRange::MantissaScale scale) noexcept
: saved_{Number::getMantissaScale()}
{
Number::setMantissaScale(scale);

View File

@@ -21,12 +21,12 @@ public:
}
[[nodiscard]] uint256 const&
as_uint256() const
asUint256() const
{
return hash_;
}
uint256&
as_uint256()
asUint256()
{
return hash_;
}
@@ -93,7 +93,7 @@ template <>
inline std::size_t
extract(SHAMapHash const& key)
{
return *reinterpret_cast<std::size_t const*>(key.as_uint256().data());
return *reinterpret_cast<std::size_t const*>(key.asUint256().data());
}
} // namespace xrpl

View File

@@ -73,7 +73,7 @@ public:
/** If this is a strong pointer, return the strong count. Otherwise return 0
*/
[[nodiscard]] std::size_t
use_count() const;
useCount() const;
/** Return true if there is a non-zero strong count. */
[[nodiscard]] bool

View File

@@ -57,10 +57,10 @@ template <class T>
std::shared_ptr<T> const&
SharedWeakCachePointer<T>::getStrong() const
{
static std::shared_ptr<T> const empty;
static std::shared_ptr<T> const kEMPTY;
if (auto p = std::get_if<std::shared_ptr<T>>(&combo_))
return *p;
return empty;
return kEMPTY;
}
template <class T>
@@ -86,7 +86,7 @@ SharedWeakCachePointer<T>::get() const
template <class T>
std::size_t
SharedWeakCachePointer<T>::use_count() const
SharedWeakCachePointer<T>::useCount() const
{
if (auto p = std::get_if<std::shared_ptr<T>>(&combo_))
return p->use_count();

View File

@@ -36,32 +36,32 @@ class SlabAllocator
struct SlabBlock
{
// A mutex to protect the freelist for this block:
std::mutex m_;
std::mutex m;
// A linked list of appropriately sized free buffers:
std::uint8_t* l_ = nullptr;
std::uint8_t* l = nullptr;
// The next memory block
SlabBlock* next_;
SlabBlock* next;
// The underlying memory block:
std::uint8_t const* const p_ = nullptr;
std::uint8_t const* const p = nullptr;
// The extent of the underlying memory block:
std::size_t const size_;
std::size_t const size;
SlabBlock(SlabBlock* next, std::uint8_t* data, std::size_t size, std::size_t item)
: next_(next), p_(data), size_(size)
: next(next), p(data), size(size)
{
// We don't need to grab the mutex here, since we're the only
// ones with access at this moment.
while (data + item <= p_ + size_)
while (data + item <= p + size)
{
// Use memcpy to avoid unaligned UB
// (will optimize to equivalent code)
std::memcpy(data, static_cast<void const*>(&l_), sizeof(std::uint8_t*));
l_ = data;
std::memcpy(data, static_cast<void const*>(&l), sizeof(std::uint8_t*));
l = data;
data += item;
}
}
@@ -83,7 +83,7 @@ class SlabAllocator
bool
own(std::uint8_t const* p) const noexcept
{
return (p >= p_) && (p < p_ + size_);
return (p >= p) && (p < p + size);
}
std::uint8_t*
@@ -92,15 +92,15 @@ class SlabAllocator
std::uint8_t* ret = nullptr; // NOLINT(misc-const-correctness)
{
std::scoped_lock const l(m_);
std::scoped_lock const l(m);
ret = l_;
ret = l;
if (ret != nullptr)
{
// Use memcpy to avoid unaligned UB
// (will optimize to equivalent code)
std::memcpy(static_cast<void*>(&l_), ret, sizeof(std::uint8_t*));
std::memcpy(static_cast<void*>(&l), ret, sizeof(std::uint8_t*));
}
}
@@ -121,12 +121,12 @@ class SlabAllocator
{
XRPL_ASSERT(own(ptr), "xrpl::SlabAllocator::SlabBlock::deallocate : own input");
std::scoped_lock const l(m_);
std::scoped_lock const l(m);
// Use memcpy to avoid unaligned UB
// (will optimize to equivalent code)
std::memcpy(ptr, static_cast<void const*>(&l_), sizeof(std::uint8_t*));
l_ = ptr;
std::memcpy(ptr, static_cast<void const*>(&l), sizeof(std::uint8_t*));
l = ptr;
}
};
@@ -201,7 +201,7 @@ public:
if (auto ret = slab->allocate())
return ret;
slab = slab->next_;
slab = slab->next;
}
// No slab can satisfy our request, so we attempt to allocate a new
@@ -242,7 +242,7 @@ public:
// Link the new slab
while (!slabs_.compare_exchange_weak(
slab->next_, slab, std::memory_order_release, std::memory_order_relaxed))
slab->next, slab, std::memory_order_release, std::memory_order_relaxed))
{
; // Nothing to do
}
@@ -265,7 +265,7 @@ public:
"xrpl::SlabAllocator::SlabAllocator::deallocate : non-null "
"input");
for (auto slab = slabs_.load(); slab != nullptr; slab = slab->next_)
for (auto slab = slabs_.load(); slab != nullptr; slab = slab->next)
{
if (slab->own(ptr))
{
@@ -294,16 +294,16 @@ public:
friend class SlabAllocatorSet;
private:
std::size_t extra;
std::size_t alloc;
std::size_t align;
std::size_t extra_;
std::size_t alloc_;
std::size_t align_;
public:
constexpr SlabConfig(
std::size_t extra_,
std::size_t alloc_ = 0,
std::size_t align_ = alignof(Type))
: extra(extra_), alloc(alloc_), align(align_)
std::size_t extra,
std::size_t alloc = 0,
std::size_t align = alignof(Type))
: extra_(extra), alloc_(alloc), align_(align)
{
}
};
@@ -313,13 +313,13 @@ public:
// Ensure that the specified allocators are sorted from smallest to
// largest by size:
std::sort(std::begin(cfg), std::end(cfg), [](SlabConfig const& a, SlabConfig const& b) {
return a.extra < b.extra;
return a.extra_ < b.extra_;
});
// We should never have two slabs of the same size
if (std::adjacent_find(
std::begin(cfg), std::end(cfg), [](SlabConfig const& a, SlabConfig const& b) {
return a.extra == b.extra;
return a.extra_ == b.extra_;
}) != cfg.end())
{
throw std::runtime_error(
@@ -328,7 +328,7 @@ public:
for (auto const& c : cfg)
{
auto& a = allocators_.emplace_back(c.extra, c.alloc, c.align);
auto& a = allocators_.emplace_back(c.extra_, c.alloc_, c.align_);
if (a.size() > maxSize_)
maxSize_ = a.size();

View File

@@ -110,7 +110,7 @@ public:
/** Shrinks the slice by moving its start forward by n characters. */
void
remove_prefix(std::size_t n)
removePrefix(std::size_t n)
{
data_ += n;
size_ -= n;
@@ -118,7 +118,7 @@ public:
/** Shrinks the slice by moving its end backward by n characters. */
void
remove_suffix(std::size_t n)
removeSuffix(std::size_t n)
{
size_ -= n;
}

View File

@@ -30,7 +30,7 @@ template <class Iterator>
std::optional<Blob>
strUnHex(std::size_t strSize, Iterator begin, Iterator end)
{
static constexpr std::array<int, 256> const digitLookupTable = []() {
static constexpr std::array<int, 256> const kDIGIT_LOOKUP_TABLE = []() {
std::array<int, 256> t{};
for (auto& x : t)
@@ -56,7 +56,7 @@ strUnHex(std::size_t strSize, Iterator begin, Iterator end)
if (strSize & 1)
{
int c = digitLookupTable[*iter++];
int c = kDIGIT_LOOKUP_TABLE[*iter++];
if (c < 0)
return {};
@@ -66,12 +66,12 @@ strUnHex(std::size_t strSize, Iterator begin, Iterator end)
while (iter != end)
{
int const cHigh = digitLookupTable[*iter++];
int const cHigh = kDIGIT_LOOKUP_TABLE[*iter++];
if (cHigh < 0)
return {};
int const cLow = digitLookupTable[*iter++];
int const cLow = kDIGIT_LOOKUP_TABLE[*iter++];
if (cLow < 0)
return {};
@@ -94,9 +94,9 @@ strViewUnHex(std::string_view strSrc)
return strUnHex(strSrc.size(), strSrc.cbegin(), strSrc.cend());
}
struct parsedURL
struct ParsedUrl
{
explicit parsedURL() = default;
explicit ParsedUrl() = default;
std::string scheme;
std::string username;
@@ -106,7 +106,7 @@ struct parsedURL
std::string path;
bool
operator==(parsedURL const& other) const
operator==(ParsedUrl const& other) const
{
return scheme == other.scheme && domain == other.domain && port == other.port &&
path == other.path;
@@ -114,7 +114,7 @@ struct parsedURL
};
bool
parseUrl(parsedURL& pUrl, std::string const& strUrl);
parseUrl(ParsedUrl& pUrl, std::string const& strUrl);
std::string
trim_whitespace(std::string str);

View File

@@ -35,7 +35,7 @@ template <
bool IsKeyCache = false,
class SharedWeakUnionPointerType = SharedWeakCachePointer<T>,
class SharedPointerType = std::shared_ptr<T>,
class Hash = hardened_hash<>,
class Hash = HardenedHash<>,
class KeyEqual = std::equal_to<Key>,
class Mutex = std::recursive_mutex>
class TaggedCache
@@ -44,7 +44,7 @@ public:
using mutex_type = Mutex;
using key_type = Key;
using mapped_type = T;
using clock_type = beast::abstract_clock<std::chrono::steady_clock>;
using clock_type = beast::AbstractClock<std::chrono::steady_clock>;
using shared_weak_combo_pointer_type = SharedWeakUnionPointerType;
using shared_pointer_type = SharedPointerType;
@@ -86,7 +86,7 @@ public:
*/
template <class KeyComparable>
bool
touch_if_exists(KeyComparable const& key);
touchIfExists(KeyComparable const& key);
using SweptPointersVector = std::vector<SharedWeakUnionPointerType>;
@@ -115,10 +115,10 @@ public:
canonicalize(key_type const& key, SharedPointerType& data, R&& replaceCallback);
bool
canonicalize_replace_cache(key_type const& key, SharedPointerType const& data);
canonicalizeReplaceCache(key_type const& key, SharedPointerType const& data);
bool
canonicalize_replace_client(key_type const& key, SharedPointerType& data);
canonicalizeReplaceClient(key_type const& key, SharedPointerType& data);
SharedPointerType
fetch(key_type const& key);
@@ -169,7 +169,7 @@ private:
initialFetch(key_type const& key, std::scoped_lock<mutex_type> const& l);
void
collect_metrics();
collectMetrics();
private:
struct Stats
@@ -179,9 +179,9 @@ private:
std::string const& prefix,
Handler const& handler,
beast::insight::Collector::ptr const& collector)
: hook(collector->make_hook(handler))
, size(collector->make_gauge(prefix, "size"))
, hit_rate(collector->make_gauge(prefix, "hit_rate"))
: hook(collector->makeHook(handler))
, size(collector->makeGauge(prefix, "size"))
, hit_rate(collector->makeGauge(prefix, "hit_rate"))
{
}
@@ -199,8 +199,7 @@ private:
public:
clock_type::time_point last_access;
explicit KeyOnlyEntry(clock_type::time_point const& last_access_)
: last_access(last_access_)
explicit KeyOnlyEntry(clock_type::time_point const& lastAccess) : last_access(lastAccess)
{
}
@@ -217,8 +216,8 @@ private:
shared_weak_combo_pointer_type ptr;
clock_type::time_point last_access;
ValueEntry(clock_type::time_point const& last_access_, shared_pointer_type const& ptr_)
: ptr(ptr_), last_access(last_access_)
ValueEntry(clock_type::time_point const& lastAccess, shared_pointer_type const& ptr)
: ptr(ptr), last_access(lastAccess)
{
}
@@ -261,7 +260,7 @@ private:
[[nodiscard]] std::thread
sweepHelper(
clock_type::time_point const& when_expire,
clock_type::time_point const& whenExpire,
[[maybe_unused]] clock_type::time_point const& now,
typename KeyValueCacheType::map_type& partition,
SweptPointersVector& stuffToSweep,
@@ -270,33 +269,33 @@ private:
[[nodiscard]] std::thread
sweepHelper(
clock_type::time_point const& when_expire,
clock_type::time_point const& whenExpire,
clock_type::time_point const& now,
typename KeyOnlyCacheType::map_type& partition,
SweptPointersVector&,
std::atomic<int>& allRemovals,
std::scoped_lock<std::recursive_mutex> const&);
beast::Journal m_journal;
clock_type& m_clock;
Stats m_stats;
beast::Journal m_journal_;
clock_type& m_clock_;
Stats m_stats_;
mutex_type mutable m_mutex;
mutex_type mutable m_mutex_;
// Used for logging
std::string m_name;
std::string m_name_;
// Desired number of cache entries (0 = ignore)
int const m_target_size;
int const m_target_size_;
// Desired maximum cache age
clock_type::duration const m_target_age;
clock_type::duration const m_target_age_;
// Number of items cached
int m_cache_count{0};
cache_type m_cache; // Hold strong reference to recent objects
std::uint64_t m_hits{0};
std::uint64_t m_misses{0};
int m_cache_count_{0};
cache_type m_cache_; // Hold strong reference to recent objects
std::uint64_t m_hits_{0};
std::uint64_t m_misses_{0};
};
} // namespace xrpl

View File

@@ -30,12 +30,12 @@ inline TaggedCache<
clock_type& clock,
beast::Journal journal,
beast::insight::Collector::ptr const& collector)
: m_journal(journal)
, m_clock(clock)
, m_stats(name, std::bind(&TaggedCache::collect_metrics, this), collector)
, m_name(name)
, m_target_size(size)
, m_target_age(expiration)
: m_journal_(journal)
, m_clock_(clock)
, m_stats_(name, std::bind(&TaggedCache::collectMetrics, this), collector)
, m_name_(name)
, m_target_size_(size)
, m_target_age_(expiration)
{
}
@@ -53,7 +53,7 @@ inline auto
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
clock() -> clock_type&
{
return m_clock;
return m_clock_;
}
template <
@@ -69,8 +69,8 @@ inline std::size_t
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
size() const
{
std::scoped_lock lock(m_mutex);
return m_cache.size();
std::scoped_lock lock(m_mutex_);
return m_cache_.size();
}
template <
@@ -86,8 +86,8 @@ inline int
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
getCacheSize() const
{
std::scoped_lock lock(m_mutex);
return m_cache_count;
std::scoped_lock lock(m_mutex_);
return m_cache_count_;
}
template <
@@ -103,8 +103,8 @@ inline int
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
getTrackSize() const
{
std::scoped_lock lock(m_mutex);
return m_cache.size();
std::scoped_lock lock(m_mutex_);
return m_cache_.size();
}
template <
@@ -120,9 +120,9 @@ inline float
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
getHitRate()
{
std::scoped_lock lock(m_mutex);
auto const total = static_cast<float>(m_hits + m_misses);
return m_hits * (100.0f / std::max(1.0f, total));
std::scoped_lock lock(m_mutex_);
auto const total = static_cast<float>(m_hits_ + m_misses_);
return m_hits_ * (100.0f / std::max(1.0f, total));
}
template <
@@ -138,9 +138,9 @@ inline void
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
clear()
{
std::scoped_lock lock(m_mutex);
m_cache.clear();
m_cache_count = 0;
std::scoped_lock lock(m_mutex_);
m_cache_.clear();
m_cache_count_ = 0;
}
template <
@@ -156,11 +156,11 @@ inline void
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
reset()
{
std::scoped_lock lock(m_mutex);
m_cache.clear();
m_cache_count = 0;
m_hits = 0;
m_misses = 0;
std::scoped_lock lock(m_mutex_);
m_cache_.clear();
m_cache_count_ = 0;
m_hits_ = 0;
m_misses_ = 0;
}
template <
@@ -175,17 +175,17 @@ template <
template <class KeyComparable>
inline bool
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
touch_if_exists(KeyComparable const& key)
touchIfExists(KeyComparable const& key)
{
std::scoped_lock lock(m_mutex);
auto const iter(m_cache.find(key));
if (iter == m_cache.end())
std::scoped_lock lock(m_mutex_);
auto const iter(m_cache_.find(key));
if (iter == m_cache_.end())
{
++m_stats.misses;
++m_stats_.misses;
return false;
}
iter->second.touch(m_clock.now());
++m_stats.hits;
iter->second.touch(m_clock_.now());
++m_stats_.hits;
return true;
}
@@ -205,53 +205,53 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
// Keep references to all the stuff we sweep
// For performance, each worker thread should exit before the swept data
// is destroyed but still within the main cache lock.
std::vector<SweptPointersVector> allStuffToSweep(m_cache.partitions());
std::vector<SweptPointersVector> allStuffToSweep(m_cache_.partitions());
clock_type::time_point const now(m_clock.now());
clock_type::time_point when_expire;
clock_type::time_point const now(m_clock_.now());
clock_type::time_point whenExpire;
auto const start = std::chrono::steady_clock::now();
{
std::scoped_lock lock(m_mutex);
std::scoped_lock lock(m_mutex_);
if (m_target_size == 0 || (static_cast<int>(m_cache.size()) <= m_target_size))
if (m_target_size_ == 0 || (static_cast<int>(m_cache_.size()) <= m_target_size_))
{
when_expire = now - m_target_age;
whenExpire = now - m_target_age_;
}
else
{
when_expire = now - m_target_age * m_target_size / m_cache.size();
whenExpire = now - m_target_age_ * m_target_size_ / m_cache_.size();
clock_type::duration const minimumAge(std::chrono::seconds(1));
if (when_expire > (now - minimumAge))
when_expire = now - minimumAge;
if (whenExpire > (now - minimumAge))
whenExpire = now - minimumAge;
JLOG(m_journal.trace())
<< m_name << " is growing fast " << m_cache.size() << " of " << m_target_size
<< " aging at " << (now - when_expire).count() << " of " << m_target_age.count();
JLOG(m_journal_.trace())
<< m_name_ << " is growing fast " << m_cache_.size() << " of " << m_target_size_
<< " aging at " << (now - whenExpire).count() << " of " << m_target_age_.count();
}
std::vector<std::thread> workers;
workers.reserve(m_cache.partitions());
workers.reserve(m_cache_.partitions());
std::atomic<int> allRemovals = 0;
for (std::size_t p = 0; p < m_cache.partitions(); ++p)
for (std::size_t p = 0; p < m_cache_.partitions(); ++p)
{
workers.push_back(sweepHelper(
when_expire, now, m_cache.map()[p], allStuffToSweep[p], allRemovals, lock));
whenExpire, now, m_cache_.map()[p], allStuffToSweep[p], allRemovals, lock));
}
for (std::thread& worker : workers)
worker.join();
m_cache_count -= allRemovals;
m_cache_count_ -= allRemovals;
}
// At this point allStuffToSweep will go out of scope outside the lock
// and decrement the reference count on each strong pointer.
JLOG(m_journal.debug()) << m_name << " TaggedCache sweep lock duration "
<< std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now() - start)
.count()
<< "ms";
JLOG(m_journal_.debug()) << m_name_ << " TaggedCache sweep lock duration "
<< std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now() - start)
.count()
<< "ms";
}
template <
@@ -269,11 +269,11 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
{
// Remove from cache, if !valid, remove from map too. Returns true if
// removed from cache
std::scoped_lock lock(m_mutex);
std::scoped_lock lock(m_mutex_);
auto cit = m_cache.find(key);
auto cit = m_cache_.find(key);
if (cit == m_cache.end())
if (cit == m_cache_.end())
return false;
Entry& entry = cit->second;
@@ -282,13 +282,13 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
if (entry.isCached())
{
--m_cache_count;
--m_cache_count_;
entry.ptr.convertToWeak();
ret = true;
}
if (!valid || entry.isExpired())
m_cache.erase(cit);
m_cache_.erase(cit);
return ret;
}
@@ -309,22 +309,22 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
{
// Return canonical value, store if needed, refresh in cache
// Return values: true=we had the data already
std::scoped_lock lock(m_mutex);
std::scoped_lock lock(m_mutex_);
auto cit = m_cache.find(key);
auto cit = m_cache_.find(key);
if (cit == m_cache.end())
if (cit == m_cache_.end())
{
m_cache.emplace(
m_cache_.emplace(
std::piecewise_construct,
std::forward_as_tuple(key),
std::forward_as_tuple(m_clock.now(), data));
++m_cache_count;
std::forward_as_tuple(m_clock_.now(), data));
++m_cache_count_;
return false;
}
Entry& entry = cit->second;
entry.touch(m_clock.now());
entry.touch(m_clock_.now());
auto shouldReplace = [&] {
if constexpr (std::is_invocable_r_v<bool, R>)
@@ -368,12 +368,12 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
data = cachedData;
}
++m_cache_count;
++m_cache_count_;
return true;
}
entry.ptr = data;
++m_cache_count;
++m_cache_count_;
return false;
}
@@ -389,7 +389,7 @@ template <
class Mutex>
inline bool
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
canonicalize_replace_cache(key_type const& key, SharedPointerType const& data)
canonicalizeReplaceCache(key_type const& key, SharedPointerType const& data)
{
return canonicalize(key, const_cast<SharedPointerType&>(data), []() { return true; });
}
@@ -405,7 +405,7 @@ template <
class Mutex>
inline bool
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
canonicalize_replace_client(key_type const& key, SharedPointerType& data)
canonicalizeReplaceClient(key_type const& key, SharedPointerType& data)
{
return canonicalize(key, data, []() { return false; });
}
@@ -423,10 +423,10 @@ inline SharedPointerType
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
fetch(key_type const& key)
{
std::scoped_lock<mutex_type> l(m_mutex);
std::scoped_lock<mutex_type> l(m_mutex_);
auto ret = initialFetch(key, l);
if (!ret)
++m_misses;
++m_misses_;
return ret;
}
@@ -451,12 +451,12 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
if constexpr (std::is_same_v<std::shared_ptr<T>, SharedPointerType>)
{
auto p = std::make_shared<T>(std::cref(value));
return canonicalize_replace_client(key, p);
return canonicalizeReplaceClient(key, p);
}
if constexpr (std::is_same_v<intr_ptr::SharedPtr<T>, SharedPointerType>)
{
auto p = intr_ptr::make_shared<T>(std::cref(value));
return canonicalize_replace_client(key, p);
return canonicalizeReplaceClient(key, p);
}
}
@@ -474,9 +474,9 @@ inline auto
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
insert(key_type const& key) -> std::enable_if_t<IsKeyCache, ReturnType>
{
std::scoped_lock lock(m_mutex);
clock_type::time_point const now(m_clock.now());
auto [it, inserted] = m_cache.emplace(
std::scoped_lock lock(m_mutex_);
clock_type::time_point const now(m_clock_.now());
auto [it, inserted] = m_cache_.emplace(
std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple(now));
if (!inserted)
it->second.last_access = now;
@@ -519,7 +519,7 @@ inline auto
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
peekMutex() -> mutex_type&
{
return m_mutex;
return m_mutex_;
}
template <
@@ -538,9 +538,9 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
std::vector<key_type> v;
{
std::scoped_lock lock(m_mutex);
v.reserve(m_cache.size());
for (auto const& _ : m_cache)
std::scoped_lock lock(m_mutex_);
v.reserve(m_cache_.size());
for (auto const& _ : m_cache_)
v.push_back(_.first);
}
@@ -560,11 +560,11 @@ inline double
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
rate() const
{
std::scoped_lock lock(m_mutex);
auto const tot = m_hits + m_misses;
std::scoped_lock lock(m_mutex_);
auto const tot = m_hits_ + m_misses_;
if (tot == 0)
return 0;
return double(m_hits) / tot;
return double(m_hits_) / tot;
}
template <
@@ -582,7 +582,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
fetch(key_type const& digest, Handler const& h)
{
{
std::scoped_lock l(m_mutex);
std::scoped_lock l(m_mutex_);
if (auto ret = initialFetch(digest, l))
return ret;
}
@@ -591,11 +591,11 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
if (!sle)
return {};
std::scoped_lock l(m_mutex);
++m_misses;
auto const [it, inserted] = m_cache.emplace(digest, Entry(m_clock.now(), std::move(sle)));
std::scoped_lock l(m_mutex_);
++m_misses_;
auto const [it, inserted] = m_cache_.emplace(digest, Entry(m_clock_.now(), std::move(sle)));
if (!inserted)
it->second.touch(m_clock.now());
it->second.touch(m_clock_.now());
return it->second.ptr.getStrong();
}
// End CachedSLEs functions.
@@ -613,27 +613,27 @@ inline SharedPointerType
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
initialFetch(key_type const& key, std::scoped_lock<mutex_type> const& l)
{
auto cit = m_cache.find(key);
if (cit == m_cache.end())
auto cit = m_cache_.find(key);
if (cit == m_cache_.end())
return {};
Entry& entry = cit->second;
if (entry.isCached())
{
++m_hits;
entry.touch(m_clock.now());
++m_hits_;
entry.touch(m_clock_.now());
return entry.ptr.getStrong();
}
entry.ptr = entry.lock();
if (entry.isCached())
{
// independent of cache size, so not counted as a hit
++m_cache_count;
entry.touch(m_clock.now());
++m_cache_count_;
entry.touch(m_clock_.now());
return entry.ptr.getStrong();
}
m_cache.erase(cit);
m_cache_.erase(cit);
return {};
}
@@ -648,19 +648,19 @@ template <
class Mutex>
inline void
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
collect_metrics()
collectMetrics()
{
m_stats.size.set(getCacheSize());
m_stats_.size.set(getCacheSize());
{
beast::insight::Gauge::value_type hit_rate(0);
beast::insight::Gauge::value_type hitRate(0);
{
std::scoped_lock lock(m_mutex);
auto const total(m_hits + m_misses);
std::scoped_lock lock(m_mutex_);
auto const total(m_hits_ + m_misses_);
if (total != 0)
hit_rate = (m_hits * 100) / total;
hitRate = (m_hits_ * 100) / total;
}
m_stats.hit_rate.set(hit_rate);
m_stats_.hit_rate.set(hitRate);
}
}
@@ -676,7 +676,7 @@ template <
inline std::thread
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
sweepHelper(
clock_type::time_point const& when_expire,
clock_type::time_point const& whenExpire,
[[maybe_unused]] clock_type::time_point const& now,
typename KeyValueCacheType::map_type& partition,
SweptPointersVector& stuffToSweep,
@@ -708,7 +708,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
++cit;
}
}
else if (cit->second.last_access <= when_expire)
else if (cit->second.last_access <= whenExpire)
{
// strong, expired
++cacheRemovals;
@@ -735,8 +735,8 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
if (mapRemovals || cacheRemovals)
{
JLOG(m_journal.debug())
<< "TaggedCache partition sweep " << m_name << ": cache = " << partition.size()
JLOG(m_journal_.debug())
<< "TaggedCache partition sweep " << m_name_ << ": cache = " << partition.size()
<< "-" << cacheRemovals << ", map-=" << mapRemovals;
}
@@ -791,8 +791,8 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
if (mapRemovals || cacheRemovals)
{
JLOG(m_journal.debug())
<< "TaggedCache partition sweep " << m_name << ": cache = " << partition.size()
JLOG(m_journal_.debug())
<< "TaggedCache partition sweep " << m_name_ << ": cache = " << partition.size()
<< "-" << cacheRemovals << ", map-=" << mapRemovals;
}

View File

@@ -28,7 +28,7 @@ namespace xrpl {
template <
class Key,
class Value,
class Hash = beast::uhash<>,
class Hash = beast::Uhash<>,
class Pred = std::equal_to<Key>,
class Allocator = std::allocator<std::pair<Key const, Value>>>
using hash_map = std::unordered_map<Key, Value, Hash, Pred, Allocator>;
@@ -36,33 +36,33 @@ using hash_map = std::unordered_map<Key, Value, Hash, Pred, Allocator>;
template <
class Key,
class Value,
class Hash = beast::uhash<>,
class Hash = beast::Uhash<>,
class Pred = std::equal_to<Key>,
class Allocator = std::allocator<std::pair<Key const, Value>>>
using hash_multimap = std::unordered_multimap<Key, Value, Hash, Pred, Allocator>;
template <
class Value,
class Hash = beast::uhash<>,
class Hash = beast::Uhash<>,
class Pred = std::equal_to<Value>,
class Allocator = std::allocator<Value>>
using hash_set = std::unordered_set<Value, Hash, Pred, Allocator>;
template <
class Value,
class Hash = beast::uhash<>,
class Hash = beast::Uhash<>,
class Pred = std::equal_to<Value>,
class Allocator = std::allocator<Value>>
using hash_multiset = std::unordered_multiset<Value, Hash, Pred, Allocator>;
// hardened_hash containers
using strong_hash = beast::xxhasher;
using strong_hash = beast::Xxhasher;
template <
class Key,
class Value,
class Hash = hardened_hash<strong_hash>,
class Hash = HardenedHash<strong_hash>,
class Pred = std::equal_to<Key>,
class Allocator = std::allocator<std::pair<Key const, Value>>>
using hardened_hash_map = std::unordered_map<Key, Value, Hash, Pred, Allocator>;
@@ -70,29 +70,29 @@ using hardened_hash_map = std::unordered_map<Key, Value, Hash, Pred, Allocator>;
template <
class Key,
class Value,
class Hash = hardened_hash<strong_hash>,
class Hash = HardenedHash<strong_hash>,
class Pred = std::equal_to<Key>,
class Allocator = std::allocator<std::pair<Key const, Value>>>
using hardened_partitioned_hash_map = partitioned_unordered_map<Key, Value, Hash, Pred, Allocator>;
using hardened_partitioned_hash_map = PartitionedUnorderedMap<Key, Value, Hash, Pred, Allocator>;
template <
class Key,
class Value,
class Hash = hardened_hash<strong_hash>,
class Hash = HardenedHash<strong_hash>,
class Pred = std::equal_to<Key>,
class Allocator = std::allocator<std::pair<Key const, Value>>>
using hardened_hash_multimap = std::unordered_multimap<Key, Value, Hash, Pred, Allocator>;
template <
class Value,
class Hash = hardened_hash<strong_hash>,
class Hash = HardenedHash<strong_hash>,
class Pred = std::equal_to<Value>,
class Allocator = std::allocator<Value>>
using hardened_hash_set = std::unordered_set<Value, Hash, Pred, Allocator>;
template <
class Value,
class Hash = hardened_hash<strong_hash>,
class Hash = HardenedHash<strong_hash>,
class Pred = std::equal_to<Value>,
class Allocator = std::allocator<Value>>
using hardened_hash_multiset = std::unordered_multiset<Value, Hash, Pred, Allocator>;

View File

@@ -21,7 +21,7 @@ public:
using period = std::ratio<1>;
using duration = std::chrono::duration<rep, period>;
using time_point = std::chrono::time_point<UptimeClock>;
static constexpr bool is_steady = std::chrono::system_clock::is_steady;
static constexpr bool kIS_STEADY = std::chrono::system_clock::is_steady;
explicit UptimeClock() = default;
@@ -29,19 +29,19 @@ public:
now(); // seconds since xrpld program start
private:
static std::atomic<rep> now_;
static std::atomic<bool> stop_;
static std::atomic<rep> now;
static std::atomic<bool> stop;
struct update_thread : private std::thread
struct UpdateThread : private std::thread
{
~update_thread();
update_thread(update_thread&&) = default;
~UpdateThread();
UpdateThread(UpdateThread&&) = default;
using std::thread::thread;
};
static update_thread
start_clock();
static UpdateThread
startClock();
};
} // namespace xrpl

View File

@@ -27,7 +27,7 @@ namespace xrpl {
namespace detail {
template <class Container, class = std::void_t<>>
struct is_contiguous_container : std::false_type
struct IsContiguousContainer : std::false_type
{
};
@@ -62,18 +62,18 @@ struct is_contiguous_container<Slice> : std::true_type
number of bits.
*/
template <std::size_t Bits, class Tag = void>
class base_uint
class BaseUint
{
static_assert((Bits % 32) == 0, "The length of a base_uint in bits must be a multiple of 32.");
static_assert(Bits >= 64, "The length of a base_uint in bits must be at least 64.");
static constexpr std::size_t WIDTH = Bits / 32;
static constexpr std::size_t kWIDTH = Bits / 32;
// This is really big-endian in byte order.
// We sometimes use std::uint32_t for speed.
std::array<std::uint32_t, WIDTH> data_;
std::array<std::uint32_t, kWIDTH> data_;
public:
//--------------------------------------------------------------------------
@@ -81,8 +81,8 @@ public:
// STL Container Interface
//
static std::size_t constexpr bytes = Bits / 8;
static_assert(sizeof(data_) == bytes, "");
static std::size_t constexpr kBYTES = Bits / 8;
static_assert(sizeof(data_) == kBYTES, "");
using size_type = std::size_t;
using difference_type = std::ptrdiff_t;
@@ -116,7 +116,7 @@ public:
iterator
end()
{
return data() + bytes;
return data() + kBYTES;
}
[[nodiscard]] const_iterator
begin() const
@@ -126,7 +126,7 @@ public:
[[nodiscard]] const_iterator
end() const
{
return data() + bytes;
return data() + kBYTES;
}
[[nodiscard]] const_iterator
cbegin() const
@@ -136,14 +136,14 @@ public:
[[nodiscard]] const_iterator
cend() const
{
return data() + bytes;
return data() + kBYTES;
}
/** Value hashing function.
The seed prevents crafted inputs from causing degenerate parent
containers.
*/
using hasher = hardened_hash<>;
using hasher = HardenedHash<>;
//--------------------------------------------------------------------------
@@ -160,16 +160,16 @@ private:
explicit VoidHelper() = default;
};
explicit base_uint(void const* data, VoidHelper)
explicit BaseUint(void const* data, VoidHelper)
{
memcpy(data_.data(), data, bytes);
memcpy(data_.data(), data, kBYTES);
}
// Helper function to initialize a base_uint from a std::string_view.
enum class ParseResult {
okay,
badLength,
badChar,
Okay,
BadLength,
BadChar,
};
constexpr Expected<decltype(data_), ParseResult>
@@ -180,7 +180,7 @@ private:
auto hexCharToUInt = [](char c, std::uint32_t shift, std::uint32_t& accum) -> ParseResult {
std::uint32_t nibble = 0xFFu;
if (c < '0' || c > 'f')
return ParseResult::badChar;
return ParseResult::BadChar;
if (c >= 'a')
{
@@ -196,11 +196,11 @@ private:
}
if (nibble > 0xFu)
return ParseResult::badChar;
return ParseResult::BadChar;
accum |= (nibble << shift);
return ParseResult::okay;
return ParseResult::Okay;
};
decltype(data_) ret{};
@@ -211,7 +211,7 @@ private:
}
if (sv.size() != size() * 2)
return Unexpected(ParseResult::badLength);
return Unexpected(ParseResult::BadLength);
std::size_t i = 0u;
auto in = sv.begin();
@@ -221,7 +221,7 @@ private:
for (std::uint32_t const shift : {4u, 0u, 12u, 8u, 20u, 16u, 28u, 24u})
{
if (auto const result = hexCharToUInt(*in++, shift, accum);
result != ParseResult::okay)
result != ParseResult::Okay)
return Unexpected(result);
}
ret[i++] = accum;
@@ -244,15 +244,15 @@ private:
}
public:
constexpr base_uint() : data_{}
constexpr BaseUint() : data_{}
{
}
constexpr base_uint(beast::Zero) : data_{}
constexpr BaseUint(beast::Zero) : data_{}
{
}
explicit base_uint(std::uint64_t b)
explicit BaseUint(std::uint64_t b)
{
*this = b;
}
@@ -260,7 +260,7 @@ public:
// This constructor is intended to be used at compile time since it might
// throw at runtime. Consider declaring this constructor consteval once
// we get to C++23.
explicit constexpr base_uint(std::string_view sv) noexcept(false)
explicit constexpr BaseUint(std::string_view sv) noexcept(false)
: data_(parseFromStringViewThrows(sv))
{
}
@@ -268,9 +268,9 @@ public:
template <
class Container,
class = std::enable_if_t<
detail::is_contiguous_container<Container>::value &&
detail::IsContiguousContainer<Container>::value &&
std::is_trivially_copyable_v<typename Container::value_type>>>
explicit base_uint(Container const& c)
explicit BaseUint(Container const& c)
{
XRPL_ASSERT(
c.size() * sizeof(typename Container::value_type) == size(),
@@ -280,9 +280,9 @@ public:
template <class Container>
std::enable_if_t<
detail::is_contiguous_container<Container>::value &&
detail::IsContiguousContainer<Container>::value &&
std::is_trivially_copyable_v<typename Container::value_type>,
base_uint&>
BaseUint&>
operator=(Container const& c)
{
XRPL_ASSERT(
@@ -295,14 +295,14 @@ public:
/* Construct from a raw pointer.
The buffer pointed to by `data` must be at least Bits/8 bytes.
*/
static base_uint
static BaseUint
fromVoid(void const* data)
{
return base_uint(data, VoidHelper());
return BaseUint(data, VoidHelper());
}
template <class T>
static std::optional<base_uint>
static std::optional<BaseUint>
fromVoidChecked(T const& from)
{
if (from.size() != size())
@@ -313,7 +313,7 @@ public:
[[nodiscard]] constexpr int
signum() const
{
for (int i = 0; i < WIDTH; i++)
for (int i = 0; i < kWIDTH; i++)
{
if (data_[i] != 0)
return 1;
@@ -325,24 +325,24 @@ public:
bool
operator!() const
{
return *this == beast::zero;
return *this == beast::kZERO;
}
constexpr base_uint
constexpr BaseUint
operator~() const
{
base_uint ret;
BaseUint ret;
for (int i = 0; i < WIDTH; i++)
for (int i = 0; i < kWIDTH; i++)
ret.data_[i] = ~data_[i];
return ret;
}
base_uint&
BaseUint&
operator=(std::uint64_t uHost)
{
*this = beast::zero;
*this = beast::kZERO;
// NOLINTBEGIN(cppcoreguidelines-pro-type-member-init)
union
{
@@ -352,43 +352,43 @@ public:
// NOLINTEND(cppcoreguidelines-pro-type-member-init)
// Put in least significant bits.
ul = boost::endian::native_to_big(uHost);
data_[WIDTH - 2] = u[0];
data_[WIDTH - 1] = u[1];
data_[kWIDTH - 2] = u[0];
data_[kWIDTH - 1] = u[1];
return *this;
}
base_uint&
operator^=(base_uint const& b)
BaseUint&
operator^=(BaseUint const& b)
{
for (int i = 0; i < WIDTH; i++)
for (int i = 0; i < kWIDTH; i++)
data_[i] ^= b.data_[i];
return *this;
}
base_uint&
operator&=(base_uint const& b)
BaseUint&
operator&=(BaseUint const& b)
{
for (int i = 0; i < WIDTH; i++)
for (int i = 0; i < kWIDTH; i++)
data_[i] &= b.data_[i];
return *this;
}
base_uint&
operator|=(base_uint const& b)
BaseUint&
operator|=(BaseUint const& b)
{
for (int i = 0; i < WIDTH; i++)
for (int i = 0; i < kWIDTH; i++)
data_[i] |= b.data_[i];
return *this;
}
base_uint&
BaseUint&
operator++()
{
// prefix operator
for (int i = WIDTH - 1; i >= 0; --i)
for (int i = kWIDTH - 1; i >= 0; --i)
{
data_[i] = boost::endian::native_to_big(boost::endian::big_to_native(data_[i]) + 1);
if (data_[i] != 0)
@@ -398,20 +398,20 @@ public:
return *this;
}
base_uint
BaseUint
operator++(int)
{
// postfix operator
base_uint const ret = *this;
BaseUint const ret = *this;
++(*this);
return ret;
}
base_uint&
BaseUint&
operator--()
{
for (int i = WIDTH - 1; i >= 0; --i)
for (int i = kWIDTH - 1; i >= 0; --i)
{
auto prev = data_[i];
data_[i] = boost::endian::native_to_big(boost::endian::big_to_native(data_[i]) - 1);
@@ -423,36 +423,36 @@ public:
return *this;
}
base_uint
BaseUint
operator--(int)
{
// postfix operator
base_uint const ret = *this;
BaseUint const ret = *this;
--(*this);
return ret;
}
[[nodiscard]] base_uint
[[nodiscard]] BaseUint
next() const
{
auto ret = *this;
return ++ret;
}
[[nodiscard]] base_uint
[[nodiscard]] BaseUint
prev() const
{
auto ret = *this;
return --ret;
}
base_uint&
operator+=(base_uint const& b)
BaseUint&
operator+=(BaseUint const& b)
{
std::uint64_t carry = 0;
for (int i = WIDTH - 1; i >= 0; i--)
for (int i = kWIDTH - 1; i >= 0; i--)
{
std::uint64_t const n = carry + boost::endian::big_to_native(data_[i]) +
boost::endian::big_to_native(b.data_[i]);
@@ -466,7 +466,7 @@ public:
template <class Hasher>
friend void
hash_append(Hasher& h, base_uint const& a) noexcept
hash_append(Hasher& h, BaseUint const& a) noexcept
{
// Do not allow any endian transformations on this memory
h(a.data_.data(), sizeof(a.data_));
@@ -506,10 +506,10 @@ public:
constexpr static std::size_t
size()
{
return bytes;
return kBYTES;
}
base_uint<Bits, Tag>&
BaseUint<Bits, Tag>&
operator=(beast::Zero)
{
data_.fill(0);
@@ -520,28 +520,28 @@ public:
[[nodiscard]] bool
isZero() const
{
return *this == beast::zero;
return *this == beast::kZERO;
}
[[nodiscard]] bool
isNonZero() const
{
return *this != beast::zero;
return *this != beast::kZERO;
}
void
zero()
{
*this = beast::zero;
*this = beast::kZERO;
}
};
using uint128 = base_uint<128>;
using uint160 = base_uint<160>;
using uint256 = base_uint<256>;
using uint192 = base_uint<192>;
using uint128 = BaseUint<128>;
using uint160 = BaseUint<160>;
using uint256 = BaseUint<256>;
using uint192 = BaseUint<192>;
template <std::size_t Bits, class Tag>
[[nodiscard]] constexpr std::strong_ordering
operator<=>(base_uint<Bits, Tag> const& lhs, base_uint<Bits, Tag> const& rhs)
operator<=>(BaseUint<Bits, Tag> const& lhs, BaseUint<Bits, Tag> const& rhs)
{
// This comparison might seem wrong on a casual inspection because it
// compares data internally stored as std::uint32_t byte-by-byte. But
@@ -562,7 +562,7 @@ operator<=>(base_uint<Bits, Tag> const& lhs, base_uint<Bits, Tag> const& rhs)
template <std::size_t Bits, typename Tag>
[[nodiscard]] constexpr bool
operator==(base_uint<Bits, Tag> const& lhs, base_uint<Bits, Tag> const& rhs)
operator==(BaseUint<Bits, Tag> const& lhs, BaseUint<Bits, Tag> const& rhs)
{
return (lhs <=> rhs) == 0;
}
@@ -570,59 +570,59 @@ operator==(base_uint<Bits, Tag> const& lhs, base_uint<Bits, Tag> const& rhs)
//------------------------------------------------------------------------------
template <std::size_t Bits, class Tag>
constexpr bool
operator==(base_uint<Bits, Tag> const& a, std::uint64_t b)
operator==(BaseUint<Bits, Tag> const& a, std::uint64_t b)
{
return a == base_uint<Bits, Tag>(b);
return a == BaseUint<Bits, Tag>(b);
}
//------------------------------------------------------------------------------
template <std::size_t Bits, class Tag>
constexpr base_uint<Bits, Tag>
operator^(base_uint<Bits, Tag> const& a, base_uint<Bits, Tag> const& b)
constexpr BaseUint<Bits, Tag>
operator^(BaseUint<Bits, Tag> const& a, BaseUint<Bits, Tag> const& b)
{
return base_uint<Bits, Tag>(a) ^= b;
return BaseUint<Bits, Tag>(a) ^= b;
}
template <std::size_t Bits, class Tag>
constexpr base_uint<Bits, Tag>
operator&(base_uint<Bits, Tag> const& a, base_uint<Bits, Tag> const& b)
constexpr BaseUint<Bits, Tag>
operator&(BaseUint<Bits, Tag> const& a, BaseUint<Bits, Tag> const& b)
{
return base_uint<Bits, Tag>(a) &= b;
return BaseUint<Bits, Tag>(a) &= b;
}
template <std::size_t Bits, class Tag>
constexpr base_uint<Bits, Tag>
operator|(base_uint<Bits, Tag> const& a, base_uint<Bits, Tag> const& b)
constexpr BaseUint<Bits, Tag>
operator|(BaseUint<Bits, Tag> const& a, BaseUint<Bits, Tag> const& b)
{
return base_uint<Bits, Tag>(a) |= b;
return BaseUint<Bits, Tag>(a) |= b;
}
template <std::size_t Bits, class Tag>
constexpr base_uint<Bits, Tag>
operator+(base_uint<Bits, Tag> const& a, base_uint<Bits, Tag> const& b)
constexpr BaseUint<Bits, Tag>
operator+(BaseUint<Bits, Tag> const& a, BaseUint<Bits, Tag> const& b)
{
return base_uint<Bits, Tag>(a) += b;
return BaseUint<Bits, Tag>(a) += b;
}
//------------------------------------------------------------------------------
template <std::size_t Bits, class Tag>
inline std::string
to_string(base_uint<Bits, Tag> const& a)
to_string(BaseUint<Bits, Tag> const& a)
{
return strHex(a.cbegin(), a.cend());
}
template <std::size_t Bits, class Tag>
inline std::string
to_short_string(base_uint<Bits, Tag> const& a)
to_short_string(BaseUint<Bits, Tag> const& a)
{
static_assert(base_uint<Bits, Tag>::bytes > 4, "For 4 bytes or less, use a native type");
static_assert(BaseUint<Bits, Tag>::kBYTES > 4, "For 4 bytes or less, use a native type");
return strHex(a.cbegin(), a.cbegin() + 4) + "...";
}
template <std::size_t Bits, class Tag>
inline std::ostream&
operator<<(std::ostream& out, base_uint<Bits, Tag> const& u)
operator<<(std::ostream& out, BaseUint<Bits, Tag> const& u)
{
return out << to_string(u);
}
@@ -650,7 +650,7 @@ static_assert(sizeof(uint256) == 256 / 8, "There should be no padding bytes");
namespace beast {
template <std::size_t Bits, class Tag>
struct is_uniquely_represented<xrpl::base_uint<Bits, Tag>> : public std::true_type
struct is_uniquely_represented<xrpl::BaseUint<Bits, Tag>> : public std::true_type
{
explicit is_uniquely_represented() = default;
};

View File

@@ -30,10 +30,10 @@ using weeks = std::chrono::duration<int, std::ratio_multiply<days::period, std::
= seconds(946684800)
*/
constexpr static std::chrono::seconds epoch_offset =
constexpr static std::chrono::seconds kEPOCH_OFFSET =
date::sys_days{date::year{2000} / 1 / 1} - date::sys_days{date::year{1970} / 1 / 1};
static_assert(epoch_offset.count() == 946684800);
static_assert(kEPOCH_OFFSET.count() == 946684800);
class NetClock
{
@@ -45,7 +45,7 @@ public:
using duration = std::chrono::duration<rep, period>;
using time_point = std::chrono::time_point<NetClock>;
static bool const is_steady = false;
static bool const kIS_STEADY = false;
};
template <class Duration>
@@ -60,7 +60,7 @@ to_string(NetClock::time_point tp)
{
// 2000-01-01 00:00:00 UTC is 946684800s from 1970-01-01 00:00:00 UTC
using namespace std::chrono;
return to_string(system_clock::time_point{tp.time_since_epoch() + epoch_offset});
return to_string(system_clock::time_point{tp.time_since_epoch() + kEPOCH_OFFSET});
}
template <class Duration>
@@ -77,23 +77,23 @@ to_string_iso(NetClock::time_point tp)
// 2000-01-01 00:00:00 UTC is 946684800s from 1970-01-01 00:00:00 UTC
// Note, NetClock::duration is seconds, as checked by static_assert
static_assert(std::is_same_v<NetClock::duration::period, std::ratio<1>>);
return to_string_iso(date::sys_time<NetClock::duration>{tp.time_since_epoch() + epoch_offset});
return to_string_iso(date::sys_time<NetClock::duration>{tp.time_since_epoch() + kEPOCH_OFFSET});
}
/** A clock for measuring elapsed time.
The epoch is unspecified.
*/
using Stopwatch = beast::abstract_clock<std::chrono::steady_clock>;
using Stopwatch = beast::AbstractClock<std::chrono::steady_clock>;
/** A manual Stopwatch for unit tests. */
using TestStopwatch = beast::manual_clock<std::chrono::steady_clock>;
using TestStopwatch = beast::ManualClock<std::chrono::steady_clock>;
/** Returns an instance of a wall clock. */
inline Stopwatch&
stopwatch()
{
using Clock = beast::basic_seconds_clock;
using Clock = beast::BasicSecondsClock;
using Facade = Clock::Clock;
return beast::get_abstract_clock<Facade, Clock>();
}

View File

@@ -18,22 +18,22 @@ template <bool = true>
seed_pair
make_seed_pair() noexcept
{
struct state_t
struct StateT
{
std::mutex mutex;
std::random_device rng;
std::mt19937_64 gen;
std::uniform_int_distribution<std::uint64_t> dist;
state_t() : gen(rng())
StateT() : gen(rng())
{
}
// state_t(state_t const&) = delete;
// state_t& operator=(state_t const&) = delete;
};
static state_t state;
std::scoped_lock const lock(state.mutex);
return {state.dist(state.gen), state.dist(state.gen)};
static StateT kSTATE;
std::scoped_lock const lock(kSTATE.mutex);
return {kSTATE.dist(kSTATE.gen), kSTATE.dist(kSTATE.gen)};
}
} // namespace detail
@@ -68,22 +68,22 @@ make_seed_pair() noexcept
see https://131002.net/siphash/#at
*/
template <class HashAlgorithm = beast::xxhasher>
class hardened_hash
template <class HashAlgorithm = beast::Xxhasher>
class HardenedHash
{
private:
detail::seed_pair m_seeds{detail::make_seed_pair<>()};
detail::seed_pair m_seeds_{detail::make_seed_pair<>()};
public:
using result_type = typename HashAlgorithm::result_type;
hardened_hash() = default;
HardenedHash() = default;
template <class T>
result_type
operator()(T const& t) const noexcept
{
HashAlgorithm h(m_seeds.first, m_seeds.second);
HashAlgorithm h(m_seeds_.first, m_seeds_.second);
hash_append(h, t);
return static_cast<result_type>(h);
}

View File

@@ -5,7 +5,7 @@
#include <optional>
namespace xrpl {
auto constexpr muldiv_max = std::numeric_limits<std::uint64_t>::max();
auto constexpr kMULDIV_MAX = std::numeric_limits<std::uint64_t>::max();
/** Return value*mul/div accurately.
Computes the result of the multiplication and division in

View File

@@ -24,7 +24,7 @@ template <>
inline std::size_t
extract(std::string const& key)
{
return ::beast::uhash<>{}(key);
return ::beast::Uhash<>{}(key);
}
template <
@@ -33,7 +33,7 @@ template <
typename Hash,
typename Pred = std::equal_to<Key>,
typename Alloc = std::allocator<std::pair<Key const, Value>>>
class partitioned_unordered_map
class PartitionedUnorderedMap
{
std::size_t partitions_;
@@ -53,46 +53,46 @@ public:
using map_type = std::unordered_map<key_type, mapped_type, hasher, key_equal, allocator_type>;
using partition_map_type = std::vector<map_type>;
struct iterator
struct Iterator
{
using iterator_category = std::forward_iterator_tag;
partition_map_type* map_{nullptr};
typename partition_map_type::iterator ait_{};
typename map_type::iterator mit_;
partition_map_type* map{nullptr};
typename partition_map_type::iterator ait{};
typename map_type::iterator mit;
iterator() = default;
Iterator() = default;
iterator(partition_map_type* map) : map_(map)
Iterator(partition_map_type* map) : map(map)
{
}
reference
operator*() const
{
return *mit_;
return *mit;
}
pointer
operator->() const
{
return &(*mit_);
return &(*mit);
}
void
inc()
{
++mit_;
while (mit_ == ait_->end())
++mit;
while (mit == ait->end())
{
++ait_;
if (ait_ == map_->end())
++ait;
if (ait == map->end())
return;
mit_ = ait_->begin();
mit = ait->begin();
}
}
// ++it
iterator&
Iterator&
operator++()
{
inc();
@@ -100,75 +100,75 @@ public:
}
// it++
iterator
Iterator
operator++(int)
{
iterator tmp(*this);
Iterator tmp(*this);
inc();
return tmp;
}
friend bool
operator==(iterator const& lhs, iterator const& rhs)
operator==(Iterator const& lhs, Iterator const& rhs)
{
return lhs.map_ == rhs.map_ && lhs.ait_ == rhs.ait_ && lhs.mit_ == rhs.mit_;
return lhs.map == rhs.map && lhs.ait == rhs.ait && lhs.mit == rhs.mit;
}
friend bool
operator!=(iterator const& lhs, iterator const& rhs)
operator!=(Iterator const& lhs, Iterator const& rhs)
{
return !(lhs == rhs);
}
};
struct const_iterator
struct ConstIterator
{
using iterator_category = std::forward_iterator_tag;
partition_map_type* map_{nullptr};
typename partition_map_type::iterator ait_{};
typename map_type::iterator mit_;
partition_map_type* map{nullptr};
typename partition_map_type::iterator ait{};
typename map_type::iterator mit;
const_iterator() = default;
ConstIterator() = default;
const_iterator(partition_map_type* map) : map_(map)
ConstIterator(partition_map_type* map) : map(map)
{
}
const_iterator(iterator const& orig)
ConstIterator(Iterator const& orig)
{
map_ = orig.map_;
ait_ = orig.ait_;
mit_ = orig.mit_;
map = orig.map;
ait = orig.ait;
mit = orig.mit;
}
const_reference
operator*() const
{
return *mit_;
return *mit;
}
const_pointer
operator->() const
{
return &(*mit_);
return &(*mit);
}
void
inc()
{
++mit_;
while (mit_ == ait_->end())
++mit;
while (mit == ait->end())
{
++ait_;
if (ait_ == map_->end())
++ait;
if (ait == map->end())
return;
mit_ = ait_->begin();
mit = ait->begin();
}
}
// ++it
const_iterator&
ConstIterator&
operator++()
{
inc();
@@ -176,22 +176,22 @@ public:
}
// it++
const_iterator
ConstIterator
operator++(int)
{
const_iterator tmp(*this);
ConstIterator tmp(*this);
inc();
return tmp;
}
friend bool
operator==(const_iterator const& lhs, const_iterator const& rhs)
operator==(ConstIterator const& lhs, ConstIterator const& rhs)
{
return lhs.map_ == rhs.map_ && lhs.ait_ == rhs.ait_ && lhs.mit_ == rhs.mit_;
return lhs.map == rhs.map && lhs.ait == rhs.ait && lhs.mit == rhs.mit;
}
friend bool
operator!=(const_iterator const& lhs, const_iterator const& rhs)
operator!=(ConstIterator const& lhs, ConstIterator const& rhs)
{
return !(lhs == rhs);
}
@@ -208,8 +208,8 @@ private:
static void
end(T& it)
{
it.ait_ = it.map_->end();
it.mit_ = it.map_->back().end();
it.ait = it.map->end();
it.mit = it.map->back().end();
}
template <class T>
@@ -227,7 +227,7 @@ private:
}
public:
partitioned_unordered_map(std::optional<std::size_t> partitions = std::nullopt)
PartitionedUnorderedMap(std::optional<std::size_t> partitions = std::nullopt)
{
// Set partitions to the number of hardware threads if the parameter
// is either empty or set to 0.
@@ -252,45 +252,45 @@ public:
return map_;
}
iterator
Iterator
begin()
{
iterator it(&map_);
Iterator it(&map_);
begin(it);
return it;
}
const_iterator
ConstIterator
cbegin() const
{
const_iterator it(&map_);
ConstIterator it(&map_);
begin(it);
return it;
}
const_iterator
ConstIterator
begin() const
{
return cbegin();
}
iterator
Iterator
end()
{
iterator it(&map_);
Iterator it(&map_);
end(it);
return it;
}
const_iterator
ConstIterator
cend() const
{
const_iterator it(&map_);
ConstIterator it(&map_);
end(it);
return it;
}
const_iterator
ConstIterator
end() const
{
return cend();
@@ -301,50 +301,50 @@ private:
void
find(key_type const& key, T& it) const
{
it.ait_ = it.map_->begin() + partitioner(key);
it.mit_ = it.ait_->find(key);
if (it.mit_ == it.ait_->end())
it.ait = it.map->begin() + partitioner(key);
it.mit = it.ait->find(key);
if (it.mit == it.ait->end())
end(it);
}
public:
iterator
Iterator
find(key_type const& key)
{
iterator it(&map_);
Iterator it(&map_);
find(key, it);
return it;
}
const_iterator
ConstIterator
find(key_type const& key) const
{
const_iterator it(&map_);
ConstIterator it(&map_);
find(key, it);
return it;
}
template <class T, class U>
std::pair<iterator, bool>
std::pair<Iterator, bool>
emplace(std::piecewise_construct_t const&, T&& keyTuple, U&& valueTuple)
{
auto const& key = std::get<0>(keyTuple);
iterator it(&map_);
it.ait_ = it.map_->begin() + partitioner(key);
auto [eit, inserted] = it.ait_->emplace(
Iterator it(&map_);
it.ait = it.map->begin() + partitioner(key);
auto [eit, inserted] = it.ait->emplace(
std::piecewise_construct, std::forward<T>(keyTuple), std::forward<U>(valueTuple));
it.mit_ = eit;
it.mit = eit;
return {it, inserted};
}
template <class T, class U>
std::pair<iterator, bool>
std::pair<Iterator, bool>
emplace(T&& key, U&& val)
{
iterator it(&map_);
it.ait_ = it.map_->begin() + partitioner(key);
auto [eit, inserted] = it.ait_->emplace(std::forward<T>(key), std::forward<U>(val));
it.mit_ = eit;
Iterator it(&map_);
it.ait = it.map->begin() + partitioner(key);
auto [eit, inserted] = it.ait->emplace(std::forward<T>(key), std::forward<U>(val));
it.mit = eit;
return {it, inserted};
}
@@ -355,19 +355,19 @@ public:
p.clear();
}
iterator
erase(const_iterator position)
Iterator
erase(ConstIterator position)
{
iterator it(&map_);
it.ait_ = position.ait_;
it.mit_ = position.ait_->erase(position.mit_);
Iterator it(&map_);
it.ait = position.ait;
it.mit = position.ait->erase(position.mit);
while (it.mit_ == it.ait_->end())
while (it.mit == it.ait->end())
{
++it.ait_;
if (it.ait_ == it.map_->end())
++it.ait;
if (it.ait == it.map->end())
break;
it.mit_ = it.ait_->begin();
it.mit = it.ait->begin();
}
return it;

View File

@@ -47,27 +47,27 @@ inline beast::xor_shift_engine&
default_prng()
{
// This is used to seed the thread-specific PRNGs on demand
static beast::xor_shift_engine seeder = [] {
static beast::xor_shift_engine kSEEDER = [] {
std::random_device rng;
std::uniform_int_distribution<std::uint64_t> distribution{1};
return beast::xor_shift_engine(distribution(rng));
}();
// This protects the seeder
static std::mutex m;
static std::mutex kM;
// The thread-specific PRNGs:
thread_local beast::xor_shift_engine engine = [] {
thread_local beast::xor_shift_engine kENGINE = [] {
std::uint64_t seed = 0;
{
std::scoped_lock const lk(m);
std::scoped_lock const lk(kM);
std::uniform_int_distribution<std::uint64_t> distribution{1};
seed = distribution(seeder);
seed = distribution(kSEEDER);
}
return beast::xor_shift_engine{seed};
}();
return engine;
return kENGINE;
}
/** Return a uniformly distributed random integer.

View File

@@ -18,29 +18,29 @@ concept SafeToCast = (std::is_integral_v<Src> && std::is_integral_v<Dest>) &&
template <class Dest, class Src>
constexpr std::enable_if_t<std::is_integral_v<Dest> && std::is_integral_v<Src>, Dest>
safe_cast(Src s) noexcept
safeCast(Src s) noexcept
{
static_assert(
std::is_signed_v<Dest> || std::is_unsigned_v<Src>, "Cannot cast signed to unsigned");
constexpr unsigned not_same = std::is_signed_v<Dest> != std::is_signed_v<Src>;
constexpr unsigned kNOT_SAME = std::is_signed_v<Dest> != std::is_signed_v<Src>;
static_assert(
sizeof(Dest) >= sizeof(Src) + not_same,
sizeof(Dest) >= sizeof(Src) + kNOT_SAME,
"Destination is too small to hold all values of source");
return static_cast<Dest>(s);
}
template <class Dest, class Src>
constexpr std::enable_if_t<std::is_enum_v<Dest> && std::is_integral_v<Src>, Dest>
safe_cast(Src s) noexcept
safeCast(Src s) noexcept
{
return static_cast<Dest>(safe_cast<std::underlying_type_t<Dest>>(s));
return static_cast<Dest>(safeCast<std::underlying_type_t<Dest>>(s));
}
template <class Dest, class Src>
constexpr std::enable_if_t<std::is_integral_v<Dest> && std::is_enum_v<Src>, Dest>
safe_cast(Src s) noexcept
safeCast(Src s) noexcept
{
return safe_cast<Dest>(static_cast<std::underlying_type_t<Src>>(s));
return safeCast<Dest>(static_cast<std::underlying_type_t<Src>>(s));
}
// unsafe_cast explicitly flags a static_cast as not necessarily able to hold
@@ -49,7 +49,7 @@ safe_cast(Src s) noexcept
template <class Dest, class Src>
constexpr std::enable_if_t<std::is_integral_v<Dest> && std::is_integral_v<Src>, Dest>
unsafe_cast(Src s) noexcept
unsafeCast(Src s) noexcept
{
static_assert(
!SafeToCast<Src, Dest>,
@@ -60,14 +60,14 @@ unsafe_cast(Src s) noexcept
template <class Dest, class Src>
constexpr std::enable_if_t<std::is_enum_v<Dest> && std::is_integral_v<Src>, Dest>
unsafe_cast(Src s) noexcept
unsafeCast(Src s) noexcept
{
return static_cast<Dest>(unsafe_cast<std::underlying_type_t<Dest>>(s));
}
template <class Dest, class Src>
constexpr std::enable_if_t<std::is_integral_v<Dest> && std::is_enum_v<Src>, Dest>
unsafe_cast(Src s) noexcept
unsafeCast(Src s) noexcept
{
return unsafe_cast<Dest>(static_cast<std::underlying_type_t<Src>>(s));
}

View File

@@ -23,171 +23,171 @@ namespace xrpl {
allowed arithmetic operations.
*/
template <class Int, class Tag>
class tagged_integer : boost::totally_ordered<
tagged_integer<Int, Tag>,
boost::integer_arithmetic<
tagged_integer<Int, Tag>,
boost::bitwise<
tagged_integer<Int, Tag>,
boost::unit_steppable<
tagged_integer<Int, Tag>,
boost::shiftable<tagged_integer<Int, Tag>>>>>>
class TaggedInteger : boost::totally_ordered<
TaggedInteger<Int, Tag>,
boost::integer_arithmetic<
TaggedInteger<Int, Tag>,
boost::bitwise<
TaggedInteger<Int, Tag>,
boost::unit_steppable<
TaggedInteger<Int, Tag>,
boost::shiftable<TaggedInteger<Int, Tag>>>>>>
{
private:
Int m_value;
Int m_value_;
public:
using value_type = Int;
using tag_type = Tag;
tagged_integer() = default;
TaggedInteger() = default;
template <
class OtherInt,
class = std::enable_if_t<std::is_integral_v<OtherInt> && sizeof(OtherInt) <= sizeof(Int)>>
explicit constexpr tagged_integer(OtherInt value) noexcept : m_value(value)
explicit constexpr TaggedInteger(OtherInt value) noexcept : m_value_(value)
{
static_assert(sizeof(tagged_integer) == sizeof(Int), "tagged_integer is adding padding");
static_assert(sizeof(TaggedInteger) == sizeof(Int), "tagged_integer is adding padding");
}
bool
operator<(tagged_integer const& rhs) const noexcept
operator<(TaggedInteger const& rhs) const noexcept
{
return m_value < rhs.m_value;
return m_value_ < rhs.m_value_;
}
bool
operator==(tagged_integer const& rhs) const noexcept
operator==(TaggedInteger const& rhs) const noexcept
{
return m_value == rhs.m_value;
return m_value_ == rhs.m_value_;
}
tagged_integer&
operator+=(tagged_integer const& rhs) noexcept
TaggedInteger&
operator+=(TaggedInteger const& rhs) noexcept
{
m_value += rhs.m_value;
m_value_ += rhs.m_value_;
return *this;
}
tagged_integer&
operator-=(tagged_integer const& rhs) noexcept
TaggedInteger&
operator-=(TaggedInteger const& rhs) noexcept
{
m_value -= rhs.m_value;
m_value_ -= rhs.m_value_;
return *this;
}
tagged_integer&
operator*=(tagged_integer const& rhs) noexcept
TaggedInteger&
operator*=(TaggedInteger const& rhs) noexcept
{
m_value *= rhs.m_value;
m_value_ *= rhs.m_value_;
return *this;
}
tagged_integer&
operator/=(tagged_integer const& rhs) noexcept
TaggedInteger&
operator/=(TaggedInteger const& rhs) noexcept
{
m_value /= rhs.m_value;
m_value_ /= rhs.m_value_;
return *this;
}
tagged_integer&
operator%=(tagged_integer const& rhs) noexcept
TaggedInteger&
operator%=(TaggedInteger const& rhs) noexcept
{
m_value %= rhs.m_value;
m_value_ %= rhs.m_value_;
return *this;
}
tagged_integer&
operator|=(tagged_integer const& rhs) noexcept
TaggedInteger&
operator|=(TaggedInteger const& rhs) noexcept
{
m_value |= rhs.m_value;
m_value_ |= rhs.m_value_;
return *this;
}
tagged_integer&
operator&=(tagged_integer const& rhs) noexcept
TaggedInteger&
operator&=(TaggedInteger const& rhs) noexcept
{
m_value &= rhs.m_value;
m_value_ &= rhs.m_value_;
return *this;
}
tagged_integer&
operator^=(tagged_integer const& rhs) noexcept
TaggedInteger&
operator^=(TaggedInteger const& rhs) noexcept
{
m_value ^= rhs.m_value;
m_value_ ^= rhs.m_value_;
return *this;
}
tagged_integer&
operator<<=(tagged_integer const& rhs) noexcept
TaggedInteger&
operator<<=(TaggedInteger const& rhs) noexcept
{
m_value <<= rhs.m_value;
m_value_ <<= rhs.m_value_;
return *this;
}
tagged_integer&
operator>>=(tagged_integer const& rhs) noexcept
TaggedInteger&
operator>>=(TaggedInteger const& rhs) noexcept
{
m_value >>= rhs.m_value;
m_value_ >>= rhs.m_value_;
return *this;
}
tagged_integer
TaggedInteger
operator~() const noexcept
{
return tagged_integer{~m_value};
return TaggedInteger{~m_value_};
}
tagged_integer
TaggedInteger
operator+() const noexcept
{
return *this;
}
tagged_integer
TaggedInteger
operator-() const noexcept
{
return tagged_integer{-m_value};
return TaggedInteger{-m_value_};
}
tagged_integer&
TaggedInteger&
operator++() noexcept
{
++m_value;
++m_value_;
return *this;
}
tagged_integer&
TaggedInteger&
operator--() noexcept
{
--m_value;
--m_value_;
return *this;
}
explicit
operator Int() const noexcept
{
return m_value;
return m_value_;
}
friend std::ostream&
operator<<(std::ostream& s, tagged_integer const& t)
operator<<(std::ostream& s, TaggedInteger const& t)
{
s << t.m_value;
s << t.m_value_;
return s;
}
friend std::istream&
operator>>(std::istream& s, tagged_integer& t)
operator>>(std::istream& s, TaggedInteger& t)
{
s >> t.m_value;
s >> t.m_value_;
return s;
}
friend std::string
to_string(tagged_integer const& t)
to_string(TaggedInteger const& t)
{
return std::to_string(t.m_value);
return std::to_string(t.m_value_);
}
};
@@ -195,8 +195,8 @@ public:
namespace beast {
template <class Int, class Tag, class HashAlgorithm>
struct is_contiguously_hashable<xrpl::tagged_integer<Int, Tag>, HashAlgorithm>
: public is_contiguously_hashable<Int, HashAlgorithm>
struct is_contiguously_hashable<xrpl::TaggedInteger<Int, Tag>, HashAlgorithm>
: public IsContiguouslyHashable<Int, HashAlgorithm>
{
explicit is_contiguously_hashable() = default;
};

View File

@@ -31,7 +31,7 @@ namespace beast {
http://en.cppreference.com/w/cpp/concept/Clock
*/
template <class Clock>
class abstract_clock
class AbstractClock
{
public:
using rep = typename Clock::rep;
@@ -40,11 +40,11 @@ public:
using time_point = typename Clock::time_point;
using clock_type = Clock;
static bool const is_steady = Clock::is_steady;
static bool const kIS_STEADY = Clock::kIS_STEADY;
virtual ~abstract_clock() = default;
abstract_clock() = default;
abstract_clock(abstract_clock const&) = default;
virtual ~AbstractClock() = default;
AbstractClock() = default;
AbstractClock(AbstractClock const&) = default;
/** Returns the current time. */
[[nodiscard]] virtual time_point
@@ -56,12 +56,12 @@ public:
namespace detail {
template <class Facade, class Clock>
struct abstract_clock_wrapper : public abstract_clock<Facade>
struct AbstractClockWrapper : public AbstractClock<Facade>
{
explicit abstract_clock_wrapper() = default;
explicit AbstractClockWrapper() = default;
using typename abstract_clock<Facade>::duration;
using typename abstract_clock<Facade>::time_point;
using typename AbstractClock<Facade>::duration;
using typename AbstractClock<Facade>::time_point;
[[nodiscard]] time_point
now() const override
@@ -80,11 +80,11 @@ struct abstract_clock_wrapper : public abstract_clock<Facade>
@tparam Clock The actual concrete clock to use.
*/
template <class Facade, class Clock = Facade>
abstract_clock<Facade>&
AbstractClock<Facade>&
get_abstract_clock()
{
static detail::abstract_clock_wrapper<Facade, Clock> clock;
return clock;
static detail::AbstractClockWrapper<Facade, Clock> kCLOCK;
return kCLOCK;
}
} // namespace beast

View File

@@ -13,19 +13,19 @@ namespace beast {
@tparam Clock A type meeting these requirements:
http://en.cppreference.com/w/cpp/concept/Clock
*/
class basic_seconds_clock
class BasicSecondsClock
{
public:
using Clock = std::chrono::steady_clock;
explicit basic_seconds_clock() = default;
explicit BasicSecondsClock() = default;
using rep = typename Clock::rep;
using period = typename Clock::period;
using duration = typename Clock::duration;
using time_point = typename Clock::time_point;
static bool const is_steady = Clock::is_steady;
static bool const kIS_STEADY = Clock::is_steady;
static time_point
now();

View File

@@ -17,18 +17,18 @@ namespace beast {
http://en.cppreference.com/w/cpp/concept/Clock
*/
template <class Clock>
class manual_clock : public abstract_clock<Clock>
class ManualClock : public AbstractClock<Clock>
{
public:
using typename abstract_clock<Clock>::rep;
using typename abstract_clock<Clock>::duration;
using typename abstract_clock<Clock>::time_point;
using typename AbstractClock<Clock>::rep;
using typename AbstractClock<Clock>::duration;
using typename AbstractClock<Clock>::time_point;
private:
time_point now_;
public:
explicit manual_clock(time_point const& now = time_point(duration(0))) : now_(now)
explicit ManualClock(time_point const& now = time_point(duration(0))) : now_(now)
{
}
@@ -51,9 +51,9 @@ public:
/** Convenience for setting the time in seconds from epoch. */
template <class Integer>
void
set(Integer seconds_from_epoch)
set(Integer secondsFromEpoch)
{
set(time_point(duration(std::chrono::seconds(seconds_from_epoch))));
set(time_point(duration(std::chrono::seconds(secondsFromEpoch))));
}
/** Advance the clock by a duration. */
@@ -68,7 +68,7 @@ public:
}
/** Convenience for advancing the clock by one second. */
manual_clock&
ManualClock&
operator++()
{
advance(std::chrono::seconds(1));

View File

@@ -5,9 +5,9 @@
namespace beast {
template <class T>
struct is_aged_container : std::false_type
struct IsAgedContainer : std::false_type
{
explicit is_aged_container() = default;
explicit IsAgedContainer() = default;
};
} // namespace beast

View File

@@ -16,5 +16,5 @@ template <
class KeyEqual = std::equal_to<Key>,
class Allocator = std::allocator<std::pair<Key const, T>>>
using aged_unordered_map =
detail::aged_unordered_container<false, true, Key, T, Clock, Hash, KeyEqual, Allocator>;
detail::AgedUnorderedContainer<false, true, Key, T, Clock, Hash, KeyEqual, Allocator>;
} // namespace beast

View File

@@ -3,10 +3,10 @@
namespace beast::detail {
// Extracts the key portion of value
template <bool maybe_map>
struct aged_associative_container_extract_t
template <bool MaybeMap>
struct AgedAssociativeContainerExtractT
{
explicit aged_associative_container_extract_t() = default;
explicit AgedAssociativeContainerExtractT() = default;
template <class Value>
decltype(Value::first) const&

View File

@@ -12,13 +12,13 @@ class aged_ordered_container;
namespace detail {
// If Iterator is SCARY then this iterator will be as well.
template <bool is_const, class Iterator>
class aged_container_iterator
template <bool IsConst, class Iterator>
class AgedContainerIterator
{
public:
using iterator_category = typename std::iterator_traits<Iterator>::iterator_category;
using value_type = std::conditional_t<
is_const,
IsConst,
typename Iterator::value_type::stashed::value_type const,
typename Iterator::value_type::stashed::value_type>;
using difference_type = typename std::iterator_traits<Iterator>::difference_type;
@@ -26,99 +26,98 @@ public:
using reference = value_type&;
using time_point = typename Iterator::value_type::stashed::time_point;
aged_container_iterator() = default;
AgedContainerIterator() = default;
// Disable constructing a const_iterator from a non-const_iterator.
// Converting between reverse and non-reverse iterators should be explicit.
template <
bool other_is_const,
bool OtherIsConst,
class OtherIterator,
class = std::enable_if_t<
(!other_is_const || is_const) &&
(!OtherIsConst || IsConst) &&
!static_cast<bool>(std::is_same_v<Iterator, OtherIterator>)>>
explicit aged_container_iterator(
aged_container_iterator<other_is_const, OtherIterator> const& other)
: m_iter(other.m_iter)
explicit AgedContainerIterator(AgedContainerIterator<OtherIsConst, OtherIterator> const& other)
: m_iter_(other.m_iter)
{
}
// Disable constructing a const_iterator from a non-const_iterator.
template <bool other_is_const, class = std::enable_if_t<!other_is_const || is_const>>
aged_container_iterator(aged_container_iterator<other_is_const, Iterator> const& other)
: m_iter(other.m_iter)
template <bool OtherIsConst, class = std::enable_if_t<!OtherIsConst || IsConst>>
AgedContainerIterator(AgedContainerIterator<OtherIsConst, Iterator> const& other)
: m_iter_(other.m_iter)
{
}
// Disable assigning a const_iterator to a non-const iterator
template <bool other_is_const, class OtherIterator>
template <bool OtherIsConst, class OtherIterator>
auto
operator=(aged_container_iterator<other_is_const, OtherIterator> const& other)
-> std::enable_if_t<!other_is_const || is_const, aged_container_iterator&>
operator=(AgedContainerIterator<OtherIsConst, OtherIterator> const& other)
-> std::enable_if_t<!OtherIsConst || IsConst, AgedContainerIterator&>
{
m_iter = other.m_iter;
m_iter_ = other.m_iter;
return *this;
}
template <bool other_is_const, class OtherIterator>
template <bool OtherIsConst, class OtherIterator>
bool
operator==(aged_container_iterator<other_is_const, OtherIterator> const& other) const
operator==(AgedContainerIterator<OtherIsConst, OtherIterator> const& other) const
{
return m_iter == other.m_iter;
return m_iter_ == other.m_iter;
}
template <bool other_is_const, class OtherIterator>
template <bool OtherIsConst, class OtherIterator>
bool
operator!=(aged_container_iterator<other_is_const, OtherIterator> const& other) const
operator!=(AgedContainerIterator<OtherIsConst, OtherIterator> const& other) const
{
return m_iter != other.m_iter;
return m_iter_ != other.m_iter;
}
aged_container_iterator&
AgedContainerIterator&
operator++()
{
++m_iter;
++m_iter_;
return *this;
}
aged_container_iterator
AgedContainerIterator
operator++(int)
{
aged_container_iterator const prev(*this);
++m_iter;
AgedContainerIterator const prev(*this);
++m_iter_;
return prev;
}
aged_container_iterator&
AgedContainerIterator&
operator--()
{
--m_iter;
--m_iter_;
return *this;
}
aged_container_iterator
AgedContainerIterator
operator--(int)
{
aged_container_iterator const prev(*this);
--m_iter;
AgedContainerIterator const prev(*this);
--m_iter_;
return prev;
}
reference
operator*() const
{
return m_iter->value;
return m_iter_->value;
}
pointer
operator->() const
{
return &m_iter->value;
return &m_iter_->value;
}
[[nodiscard]] time_point const&
when() const
{
return m_iter->when;
return m_iter_->when;
}
private:
@@ -132,17 +131,17 @@ private:
friend class aged_container_iterator;
template <class OtherIterator>
aged_container_iterator(OtherIterator iter) : m_iter(std::move(iter))
AgedContainerIterator(OtherIterator iter) : m_iter_(std::move(iter))
{
}
[[nodiscard]] Iterator const&
iterator() const
{
return m_iter;
return m_iter_;
}
Iterator m_iter;
Iterator m_iter_;
};
} // namespace detail

File diff suppressed because it is too large Load Diff

View File

@@ -14,25 +14,25 @@
namespace beast::detail {
template <class T>
struct is_empty_base_optimization_derived
struct IsEmptyBaseOptimizationDerived
: std::integral_constant<bool, std::is_empty_v<T> && !boost::is_final<T>::value>
{
};
template <class T, int UniqueID = 0, bool isDerived = is_empty_base_optimization_derived<T>::value>
class empty_base_optimization : private T
template <class T, int UniqueID = 0, bool IsDerived = IsEmptyBaseOptimizationDerived<T>::value>
class EmptyBaseOptimization : private T
{
public:
empty_base_optimization() = default;
empty_base_optimization(empty_base_optimization&&) = default;
empty_base_optimization(empty_base_optimization const&) = default;
empty_base_optimization&
operator=(empty_base_optimization&&) = default;
empty_base_optimization&
operator=(empty_base_optimization const&) = default;
EmptyBaseOptimization() = default;
EmptyBaseOptimization(EmptyBaseOptimization&&) = default;
EmptyBaseOptimization(EmptyBaseOptimization const&) = default;
EmptyBaseOptimization&
operator=(EmptyBaseOptimization&&) = default;
EmptyBaseOptimization&
operator=(EmptyBaseOptimization const&) = default;
template <class Arg1, class... ArgN>
explicit empty_base_optimization(Arg1&& arg1, ArgN&&... argn)
explicit EmptyBaseOptimization(Arg1&& arg1, ArgN&&... argn)
: T(std::forward<Arg1>(arg1), std::forward<ArgN>(argn)...)
{
}

View File

@@ -45,8 +45,8 @@ class ListNode
template <typename>
friend class ListIterator;
ListNode* m_next = nullptr;
ListNode* m_prev = nullptr;
ListNode* m_next_ = nullptr;
ListNode* m_prev_ = nullptr;
};
//------------------------------------------------------------------------------
@@ -62,12 +62,12 @@ public:
using reference = value_type&;
using size_type = std::size_t;
ListIterator(N* node = nullptr) noexcept : m_node(node)
ListIterator(N* node = nullptr) noexcept : m_node_(node)
{
}
template <typename M>
ListIterator(ListIterator<M> const& other) noexcept : m_node(other.m_node)
ListIterator(ListIterator<M> const& other) noexcept : m_node_(other.m_node)
{
}
@@ -75,7 +75,7 @@ public:
bool
operator==(ListIterator<M> const& other) const noexcept
{
return m_node == other.m_node;
return m_node_ == other.m_node;
}
template <typename M>
@@ -131,22 +131,22 @@ private:
[[nodiscard]] reference
dereference() const noexcept
{
return static_cast<reference>(*m_node);
return static_cast<reference>(*m_node_);
}
void
increment() noexcept
{
m_node = m_node->m_next;
m_node_ = m_node_->m_next;
}
void
decrement() noexcept
{
m_node = m_node->m_prev;
m_node_ = m_node_->m_prev;
}
N* m_node;
N* m_node_;
};
} // namespace detail
@@ -275,8 +275,8 @@ public:
/** Create an empty list. */
List()
{
m_head.m_prev = nullptr; // identifies the head
m_tail.m_next = nullptr; // identifies the tail
m_head_.m_prev = nullptr; // identifies the head
m_tail_.m_next = nullptr; // identifies the tail
clear();
}
@@ -297,7 +297,7 @@ public:
[[nodiscard]] size_type
size() const noexcept
{
return m_size;
return m_size_;
}
/** Obtain a reference to the first element.
@@ -307,7 +307,7 @@ public:
reference
front() noexcept
{
return element_from(m_head.m_next);
return element_from(m_head_.m_next);
}
/** Obtain a const reference to the first element.
@@ -317,7 +317,7 @@ public:
[[nodiscard]] const_reference
front() const noexcept
{
return element_from(m_head.m_next);
return element_from(m_head_.m_next);
}
/** Obtain a reference to the last element.
@@ -327,7 +327,7 @@ public:
reference
back() noexcept
{
return element_from(m_tail.m_prev);
return element_from(m_tail_.m_prev);
}
/** Obtain a const reference to the last element.
@@ -337,7 +337,7 @@ public:
[[nodiscard]] const_reference
back() const noexcept
{
return element_from(m_tail.m_prev);
return element_from(m_tail_.m_prev);
}
/** Obtain an iterator to the beginning of the list.
@@ -346,7 +346,7 @@ public:
iterator
begin() noexcept
{
return iterator(m_head.m_next);
return iterator(m_head_.m_next);
}
/** Obtain a const iterator to the beginning of the list.
@@ -355,7 +355,7 @@ public:
[[nodiscard]] const_iterator
begin() const noexcept
{
return const_iterator(m_head.m_next);
return const_iterator(m_head_.m_next);
}
/** Obtain a const iterator to the beginning of the list.
@@ -364,7 +364,7 @@ public:
[[nodiscard]] const_iterator
cbegin() const noexcept
{
return const_iterator(m_head.m_next);
return const_iterator(m_head_.m_next);
}
/** Obtain a iterator to the end of the list.
@@ -373,7 +373,7 @@ public:
iterator
end() noexcept
{
return iterator(&m_tail);
return iterator(&m_tail_);
}
/** Obtain a const iterator to the end of the list.
@@ -382,7 +382,7 @@ public:
[[nodiscard]] const_iterator
end() const noexcept
{
return const_iterator(&m_tail);
return const_iterator(&m_tail_);
}
/** Obtain a const iterator to the end of the list
@@ -391,7 +391,7 @@ public:
[[nodiscard]] const_iterator
cend() const noexcept
{
return const_iterator(&m_tail);
return const_iterator(&m_tail_);
}
/** Clear the list.
@@ -400,9 +400,9 @@ public:
void
clear() noexcept
{
m_head.m_next = &m_tail;
m_tail.m_prev = &m_head;
m_size = 0;
m_head_.m_next = &m_tail_;
m_tail_.m_prev = &m_head_;
m_size_ = 0;
}
/** Insert an element.
@@ -419,7 +419,7 @@ public:
node->m_prev = node->m_next->m_prev;
node->m_next->m_prev = node;
node->m_prev->m_next = node;
++m_size;
++m_size_;
return iterator(node);
}
@@ -434,11 +434,11 @@ public:
if (!other.empty())
{
Node* before = &*pos;
other.m_head.m_next->m_prev = before->m_prev;
before->m_prev->m_next = other.m_head.m_next;
other.m_tail.m_prev->m_next = before;
before->m_prev = other.m_tail.m_prev;
m_size += other.m_size;
other.m_head_.m_next->m_prev = before->m_prev;
before->m_prev->m_next = other.m_head_.m_next;
other.m_tail_.m_prev->m_next = before;
before->m_prev = other.m_tail_.m_prev;
m_size_ += other.m_size_;
other.clear();
}
}
@@ -455,7 +455,7 @@ public:
++pos;
node->m_next->m_prev = node->m_prev;
node->m_prev->m_next = node->m_next;
--m_size;
--m_size_;
return pos;
}
@@ -464,7 +464,7 @@ public:
@param element The element to insert.
*/
iterator
push_front(T& element) noexcept
pushFront(T& element) noexcept
{
return insert(begin(), element);
}
@@ -474,7 +474,7 @@ public:
@return A reference to the popped element.
*/
T&
pop_front() noexcept
popFront() noexcept
{
T& element(front());
erase(begin());
@@ -486,7 +486,7 @@ public:
@param element The element to append.
*/
iterator
push_back(T& element) noexcept
pushBack(T& element) noexcept
{
return insert(end(), element);
}
@@ -496,7 +496,7 @@ public:
@return A reference to the popped element.
*/
T&
pop_back() noexcept
popBack() noexcept
{
T& element(back());
erase(--end());
@@ -539,7 +539,7 @@ public:
@return An iterator to the element.
*/
iterator
iterator_to(T& element) const noexcept
iteratorTo(T& element) const noexcept
{
return iterator(static_cast<Node*>(&element));
}
@@ -550,28 +550,28 @@ public:
@return A const iterator to the element.
*/
[[nodiscard]] const_iterator
const_iterator_to(T const& element) const noexcept
constIteratorTo(T const& element) const noexcept
{
return const_iterator(static_cast<Node const*>(&element));
}
private:
reference
element_from(Node* node) noexcept
elementFrom(Node* node) noexcept
{
return *(static_cast<pointer>(node));
}
const_reference
element_from(Node const* node) const noexcept
elementFrom(Node const* node) const noexcept
{
return *(static_cast<const_pointer>(node));
}
private:
size_type m_size = 0u;
Node m_head;
Node m_tail;
size_type m_size_ = 0u;
Node m_head_;
Node m_tail_;
};
} // namespace beast

View File

@@ -26,27 +26,27 @@ public:
LockFreeStackIterator() = default;
LockFreeStackIterator(NodePtr node) : m_node(node)
LockFreeStackIterator(NodePtr node) : m_node_(node)
{
}
template <bool OtherIsConst>
explicit LockFreeStackIterator(LockFreeStackIterator<Container, OtherIsConst> const& other)
: m_node(other.m_node)
: m_node_(other.m_node)
{
}
LockFreeStackIterator&
operator=(NodePtr node)
{
m_node = node;
m_node_ = node;
return static_cast<LockFreeStackIterator&>(*this);
}
LockFreeStackIterator&
operator++()
{
m_node = m_node->m_next.load();
m_node_ = m_node_->m_next.load();
return static_cast<LockFreeStackIterator&>(*this);
}
@@ -54,14 +54,14 @@ public:
operator++(int)
{
LockFreeStackIterator result(*this);
m_node = m_node->m_next;
m_node_ = m_node_->m_next;
return result;
}
NodePtr
node() const
{
return m_node;
return m_node_;
}
reference
@@ -73,11 +73,11 @@ public:
pointer
operator->() const
{
return static_cast<pointer>(m_node);
return static_cast<pointer>(m_node_);
}
private:
NodePtr m_node{};
NodePtr m_node_{};
};
//------------------------------------------------------------------------------
@@ -121,11 +121,11 @@ public:
class Node
{
public:
Node() : m_next(nullptr)
Node() : m_next_(nullptr)
{
}
explicit Node(Node* next) : m_next(next)
explicit Node(Node* next) : m_next_(next)
{
}
@@ -139,7 +139,7 @@ public:
template <class Container, bool IsConst>
friend class LockFreeStackIterator;
std::atomic<Node*> m_next;
std::atomic<Node*> m_next_;
};
public:
@@ -153,7 +153,7 @@ public:
using iterator = LockFreeStackIterator<LockFreeStack<Element, Tag>, false>;
using const_iterator = LockFreeStackIterator<LockFreeStack<Element, Tag>, true>;
LockFreeStack() : m_end(nullptr), m_head(&m_end)
LockFreeStack() : m_end_(nullptr), m_head_(&m_end_)
{
}
@@ -165,7 +165,7 @@ public:
[[nodiscard]] bool
empty() const
{
return m_head.load() == &m_end;
return m_head_.load() == &m_end_;
}
/** Push a node onto the stack.
@@ -181,16 +181,16 @@ public:
*/
// VFALCO NOTE Fix this, shouldn't it be a reference like intrusive list?
bool
push_front(Node* node)
pushFront(Node* node)
{
bool first = false;
Node* old_head = m_head.load(std::memory_order_relaxed);
Node* oldHead = m_head_.load(std::memory_order_relaxed);
do
{
first = (old_head == &m_end);
node->m_next = old_head;
} while (!m_head.compare_exchange_strong(
old_head, node, std::memory_order_release, std::memory_order_relaxed));
first = (oldHead == &m_end_);
node->m_next_ = oldHead;
} while (!m_head_.compare_exchange_strong(
oldHead, node, std::memory_order_release, std::memory_order_relaxed));
return first;
}
@@ -204,17 +204,17 @@ public:
was empty.
*/
Element*
pop_front()
popFront()
{
Node* node = m_head.load();
Node* new_head = nullptr;
Node* node = m_head_.load();
Node* newHead = nullptr;
do
{
if (node == &m_end)
if (node == &m_end_)
return nullptr;
new_head = node->m_next.load();
} while (!m_head.compare_exchange_strong(
node, new_head, std::memory_order_release, std::memory_order_relaxed));
newHead = node->m_next_.load();
} while (!m_head_.compare_exchange_strong(
node, newHead, std::memory_order_release, std::memory_order_relaxed));
return static_cast<Element*>(node);
}
@@ -228,43 +228,43 @@ public:
iterator
begin()
{
return iterator(m_head.load());
return iterator(m_head_.load());
}
iterator
end()
{
return iterator(&m_end);
return iterator(&m_end_);
}
[[nodiscard]] const_iterator
begin() const
{
return const_iterator(m_head.load());
return const_iterator(m_head_.load());
}
[[nodiscard]] const_iterator
end() const
{
return const_iterator(&m_end);
return const_iterator(&m_end_);
}
[[nodiscard]] const_iterator
cbegin() const
{
return const_iterator(m_head.load());
return const_iterator(m_head_.load());
}
[[nodiscard]] const_iterator
cend() const
{
return const_iterator(&m_end);
return const_iterator(&m_end_);
}
/** @} */
private:
Node m_end;
std::atomic<Node*> m_head;
Node m_end_;
std::atomic<Node*> m_head_;
};
} // namespace beast

View File

@@ -66,28 +66,28 @@ maybe_reverse_bytes(T& t, Hasher&)
// then x and y have the same bit pattern representation.
template <class T>
struct is_uniquely_represented
struct IsUniquelyRepresented
: public std::integral_constant<
bool,
std::is_integral_v<T> || std::is_enum_v<T> || std::is_pointer_v<T>>
{
explicit is_uniquely_represented() = default;
explicit IsUniquelyRepresented() = default;
};
template <class T>
struct is_uniquely_represented<T const> : public is_uniquely_represented<T>
struct is_uniquely_represented<T const> : public IsUniquelyRepresented<T>
{
explicit is_uniquely_represented() = default;
};
template <class T>
struct is_uniquely_represented<T volatile> : public is_uniquely_represented<T>
struct is_uniquely_represented<T volatile> : public IsUniquelyRepresented<T>
{
explicit is_uniquely_represented() = default;
};
template <class T>
struct is_uniquely_represented<T const volatile> : public is_uniquely_represented<T>
struct is_uniquely_represented<T const volatile> : public IsUniquelyRepresented<T>
{
explicit is_uniquely_represented() = default;
};
@@ -98,7 +98,7 @@ template <class T, class U>
struct is_uniquely_represented<std::pair<T, U>>
: public std::integral_constant<
bool,
is_uniquely_represented<T>::value && is_uniquely_represented<U>::value &&
IsUniquelyRepresented<T>::value && IsUniquelyRepresented<U>::value &&
sizeof(T) + sizeof(U) == sizeof(std::pair<T, U>)>
{
explicit is_uniquely_represented() = default;
@@ -110,7 +110,7 @@ template <class... T>
struct is_uniquely_represented<std::tuple<T...>>
: public std::integral_constant<
bool,
std::conjunction_v<is_uniquely_represented<T>...> &&
std::conjunction_v<IsUniquelyRepresented<T>...> &&
sizeof(std::tuple<T...>) == (sizeof(T) + ...)>
{
explicit is_uniquely_represented() = default;
@@ -119,7 +119,7 @@ struct is_uniquely_represented<std::tuple<T...>>
// is_uniquely_represented<T[N]>
template <class T, std::size_t N>
struct is_uniquely_represented<T[N]> : public is_uniquely_represented<T>
struct is_uniquely_represented<T[N]> : public IsUniquelyRepresented<T>
{
explicit is_uniquely_represented() = default;
};
@@ -130,7 +130,7 @@ template <class T, std::size_t N>
struct is_uniquely_represented<std::array<T, N>>
: public std::integral_constant<
bool,
is_uniquely_represented<T>::value && sizeof(T) * N == sizeof(std::array<T, N>)>
IsUniquelyRepresented<T>::value && sizeof(T) * N == sizeof(std::array<T, N>)>
{
explicit is_uniquely_represented() = default;
};
@@ -150,20 +150,20 @@ struct is_uniquely_represented<std::array<T, N>>
*/
/** @{ */
template <class T, class HashAlgorithm>
struct is_contiguously_hashable
struct IsContiguouslyHashable
: public std::integral_constant<
bool,
is_uniquely_represented<T>::value &&
(sizeof(T) == 1 || HashAlgorithm::endian == boost::endian::order::native)>
IsUniquelyRepresented<T>::value &&
(sizeof(T) == 1 || HashAlgorithm::kENDIAN == boost::endian::order::native)>
{
explicit is_contiguously_hashable() = default;
explicit IsContiguouslyHashable() = default;
};
template <class T, std::size_t N, class HashAlgorithm>
struct is_contiguously_hashable<T[N], HashAlgorithm>
: public std::integral_constant<
bool,
is_uniquely_represented<T[N]>::value &&
IsUniquelyRepresented<T[N]>::value &&
(sizeof(T) == 1 || HashAlgorithm::endian == boost::endian::order::native)>
{
explicit is_contiguously_hashable() = default;
@@ -200,7 +200,7 @@ struct is_contiguously_hashable<T[N], HashAlgorithm>
// scalars
template <class Hasher, class T>
inline std::enable_if_t<is_contiguously_hashable<T, Hasher>::value>
inline std::enable_if_t<IsContiguouslyHashable<T, Hasher>::value>
hash_append(Hasher& h, T const& t) noexcept
{
// NOLINTNEXTLINE(bugprone-sizeof-expression)
@@ -209,7 +209,7 @@ hash_append(Hasher& h, T const& t) noexcept
template <class Hasher, class T>
inline std::enable_if_t<
!is_contiguously_hashable<T, Hasher>::value &&
!IsContiguouslyHashable<T, Hasher>::value &&
(std::is_integral_v<T> || std::is_pointer_v<T> || std::is_enum_v<T>)>
hash_append(Hasher& h, T t) noexcept
{
@@ -239,35 +239,35 @@ hash_append(Hasher& h, std::nullptr_t) noexcept
// Forward declarations for ADL purposes
template <class Hasher, class T, std::size_t N>
std::enable_if_t<!is_contiguously_hashable<T, Hasher>::value>
std::enable_if_t<!IsContiguouslyHashable<T, Hasher>::value>
hash_append(Hasher& h, T (&a)[N]) noexcept;
template <class Hasher, class CharT, class Traits, class Alloc>
std::enable_if_t<!is_contiguously_hashable<CharT, Hasher>::value>
std::enable_if_t<!IsContiguouslyHashable<CharT, Hasher>::value>
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept;
template <class Hasher, class CharT, class Traits, class Alloc>
std::enable_if_t<is_contiguously_hashable<CharT, Hasher>::value>
std::enable_if_t<IsContiguouslyHashable<CharT, Hasher>::value>
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept;
template <class Hasher, class T, class U>
std::enable_if_t<!is_contiguously_hashable<std::pair<T, U>, Hasher>::value>
std::enable_if_t<!IsContiguouslyHashable<std::pair<T, U>, Hasher>::value>
hash_append(Hasher& h, std::pair<T, U> const& p) noexcept;
template <class Hasher, class T, class Alloc>
std::enable_if_t<!is_contiguously_hashable<T, Hasher>::value>
std::enable_if_t<!IsContiguouslyHashable<T, Hasher>::value>
hash_append(Hasher& h, std::vector<T, Alloc> const& v) noexcept;
template <class Hasher, class T, class Alloc>
std::enable_if_t<is_contiguously_hashable<T, Hasher>::value>
std::enable_if_t<IsContiguouslyHashable<T, Hasher>::value>
hash_append(Hasher& h, std::vector<T, Alloc> const& v) noexcept;
template <class Hasher, class T, std::size_t N>
std::enable_if_t<!is_contiguously_hashable<std::array<T, N>, Hasher>::value>
std::enable_if_t<!IsContiguouslyHashable<std::array<T, N>, Hasher>::value>
hash_append(Hasher& h, std::array<T, N> const& a) noexcept;
template <class Hasher, class... T>
std::enable_if_t<!is_contiguously_hashable<std::tuple<T...>, Hasher>::value>
std::enable_if_t<!IsContiguouslyHashable<std::tuple<T...>, Hasher>::value>
hash_append(Hasher& h, std::tuple<T...> const& t) noexcept;
template <class Hasher, class Key, class T, class Hash, class Pred, class Alloc>
@@ -279,10 +279,10 @@ void
hash_append(Hasher& h, std::unordered_set<Key, Hash, Pred, Alloc> const& s);
template <class Hasher, class Key, class Compare, class Alloc>
std::enable_if_t<!is_contiguously_hashable<Key, Hasher>::value>
std::enable_if_t<!IsContiguouslyHashable<Key, Hasher>::value>
hash_append(Hasher& h, boost::container::flat_set<Key, Compare, Alloc> const& v) noexcept;
template <class Hasher, class Key, class Compare, class Alloc>
std::enable_if_t<is_contiguously_hashable<Key, Hasher>::value>
std::enable_if_t<IsContiguouslyHashable<Key, Hasher>::value>
hash_append(Hasher& h, boost::container::flat_set<Key, Compare, Alloc> const& v) noexcept;
template <class Hasher, class T0, class T1, class... T>
void
@@ -291,7 +291,7 @@ hash_append(Hasher& h, T0 const& t0, T1 const& t1, T const&... t) noexcept;
// c-array
template <class Hasher, class T, std::size_t N>
std::enable_if_t<!is_contiguously_hashable<T, Hasher>::value>
std::enable_if_t<!IsContiguouslyHashable<T, Hasher>::value>
hash_append(Hasher& h, T (&a)[N]) noexcept
{
for (auto const& t : a)
@@ -301,7 +301,7 @@ hash_append(Hasher& h, T (&a)[N]) noexcept
// basic_string
template <class Hasher, class CharT, class Traits, class Alloc>
inline std::enable_if_t<!is_contiguously_hashable<CharT, Hasher>::value>
inline std::enable_if_t<!IsContiguouslyHashable<CharT, Hasher>::value>
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept
{
for (auto c : s)
@@ -310,7 +310,7 @@ hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcep
}
template <class Hasher, class CharT, class Traits, class Alloc>
inline std::enable_if_t<is_contiguously_hashable<CharT, Hasher>::value>
inline std::enable_if_t<IsContiguouslyHashable<CharT, Hasher>::value>
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept
{
h(s.data(), s.size() * sizeof(CharT));
@@ -320,7 +320,7 @@ hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcep
// pair
template <class Hasher, class T, class U>
inline std::enable_if_t<!is_contiguously_hashable<std::pair<T, U>, Hasher>::value>
inline std::enable_if_t<!IsContiguouslyHashable<std::pair<T, U>, Hasher>::value>
hash_append(Hasher& h, std::pair<T, U> const& p) noexcept
{
hash_append(h, p.first, p.second);
@@ -329,7 +329,7 @@ hash_append(Hasher& h, std::pair<T, U> const& p) noexcept
// vector
template <class Hasher, class T, class Alloc>
inline std::enable_if_t<!is_contiguously_hashable<T, Hasher>::value>
inline std::enable_if_t<!IsContiguouslyHashable<T, Hasher>::value>
hash_append(Hasher& h, std::vector<T, Alloc> const& v) noexcept
{
for (auto const& t : v)
@@ -338,7 +338,7 @@ hash_append(Hasher& h, std::vector<T, Alloc> const& v) noexcept
}
template <class Hasher, class T, class Alloc>
inline std::enable_if_t<is_contiguously_hashable<T, Hasher>::value>
inline std::enable_if_t<IsContiguouslyHashable<T, Hasher>::value>
hash_append(Hasher& h, std::vector<T, Alloc> const& v) noexcept
{
h(v.data(), v.size() * sizeof(T));
@@ -348,7 +348,7 @@ hash_append(Hasher& h, std::vector<T, Alloc> const& v) noexcept
// array
template <class Hasher, class T, std::size_t N>
std::enable_if_t<!is_contiguously_hashable<std::array<T, N>, Hasher>::value>
std::enable_if_t<!IsContiguouslyHashable<std::array<T, N>, Hasher>::value>
hash_append(Hasher& h, std::array<T, N> const& a) noexcept
{
for (auto const& t : a)
@@ -356,14 +356,14 @@ hash_append(Hasher& h, std::array<T, N> const& a) noexcept
}
template <class Hasher, class Key, class Compare, class Alloc>
std::enable_if_t<!is_contiguously_hashable<Key, Hasher>::value>
std::enable_if_t<!IsContiguouslyHashable<Key, Hasher>::value>
hash_append(Hasher& h, boost::container::flat_set<Key, Compare, Alloc> const& v) noexcept
{
for (auto const& t : v)
hash_append(h, t);
}
template <class Hasher, class Key, class Compare, class Alloc>
std::enable_if_t<is_contiguously_hashable<Key, Hasher>::value>
std::enable_if_t<IsContiguouslyHashable<Key, Hasher>::value>
hash_append(Hasher& h, boost::container::flat_set<Key, Compare, Alloc> const& v) noexcept
{
h(&(v.begin()), v.size() * sizeof(Key));
@@ -395,7 +395,7 @@ tuple_hash(Hasher& h, std::tuple<T...> const& t, std::index_sequence<I...>) noex
} // namespace detail
template <class Hasher, class... T>
inline std::enable_if_t<!is_contiguously_hashable<std::tuple<T...>, Hasher>::value>
inline std::enable_if_t<!IsContiguouslyHashable<std::tuple<T...>, Hasher>::value>
hash_append(Hasher& h, std::tuple<T...> const& t) noexcept
{
detail::tuple_hash(h, t, std::index_sequence_for<T...>{});

View File

@@ -6,10 +6,10 @@
namespace beast {
// Universal hash function
template <class Hasher = xxhasher>
struct uhash
template <class Hasher = Xxhasher>
struct Uhash
{
uhash() = default;
Uhash() = default;
using result_type = typename Hasher::result_type;

View File

@@ -12,7 +12,7 @@
namespace beast {
class xxhasher
class Xxhasher
{
public:
using result_type = std::size_t;
@@ -21,9 +21,9 @@ private:
static_assert(sizeof(std::size_t) == 8, "requires 64-bit std::size_t");
// Have an internal buffer to avoid the streaming API
// A 64-byte buffer should to be big enough for us
static constexpr std::size_t INTERNAL_BUFFER_SIZE = 64;
static constexpr std::size_t kINTERNAL_BUFFER_SIZE = 64;
alignas(64) std::array<std::uint8_t, INTERNAL_BUFFER_SIZE> buffer_{};
alignas(64) std::array<std::uint8_t, kINTERNAL_BUFFER_SIZE> buffer_{};
std::span<std::uint8_t> readBuffer_;
std::span<std::uint8_t> writeBuffer_;
@@ -102,18 +102,18 @@ private:
}
public:
static constexpr auto const endian = boost::endian::order::native;
static constexpr auto const kENDIAN = boost::endian::order::native;
xxhasher(xxhasher const&) = delete;
xxhasher&
operator=(xxhasher const&) = delete;
Xxhasher(Xxhasher const&) = delete;
Xxhasher&
operator=(Xxhasher const&) = delete;
xxhasher()
Xxhasher()
{
resetBuffers();
}
~xxhasher() noexcept
~Xxhasher() noexcept
{
if (state_ != nullptr)
{
@@ -122,13 +122,13 @@ public:
}
template <class Seed, std::enable_if_t<std::is_unsigned_v<Seed>>* = nullptr>
explicit xxhasher(Seed seed) : seed_(seed)
explicit Xxhasher(Seed seed) : seed_(seed)
{
resetBuffers();
}
template <class Seed, std::enable_if_t<std::is_unsigned_v<Seed>>* = nullptr>
xxhasher(Seed seed, Seed) : seed_(seed)
Xxhasher(Seed seed, Seed) : seed_(seed)
{
resetBuffers();
}

View File

@@ -42,13 +42,13 @@ public:
/** @{ */
template <class Handler>
Hook
make_hook(Handler handler)
makeHook(Handler handler)
{
return make_hook(HookImpl::HandlerType(handler));
return makeHook(HookImpl::HandlerType(handler));
}
virtual Hook
make_hook(HookImpl::HandlerType const& handler) = 0;
makeHook(HookImpl::HandlerType const& handler) = 0;
/** @} */
/** Create a counter with the specified name.
@@ -56,14 +56,14 @@ public:
*/
/** @{ */
virtual Counter
make_counter(std::string const& name) = 0;
makeCounter(std::string const& name) = 0;
Counter
make_counter(std::string const& prefix, std::string const& name)
makeCounter(std::string const& prefix, std::string const& name)
{
if (prefix.empty())
return make_counter(name);
return make_counter(prefix + "." + name);
return makeCounter(name);
return makeCounter(prefix + "." + name);
}
/** @} */
@@ -72,14 +72,14 @@ public:
*/
/** @{ */
virtual Event
make_event(std::string const& name) = 0;
makeEvent(std::string const& name) = 0;
Event
make_event(std::string const& prefix, std::string const& name)
makeEvent(std::string const& prefix, std::string const& name)
{
if (prefix.empty())
return make_event(name);
return make_event(prefix + "." + name);
return makeEvent(name);
return makeEvent(prefix + "." + name);
}
/** @} */
@@ -88,14 +88,14 @@ public:
*/
/** @{ */
virtual Gauge
make_gauge(std::string const& name) = 0;
makeGauge(std::string const& name) = 0;
Gauge
make_gauge(std::string const& prefix, std::string const& name)
makeGauge(std::string const& prefix, std::string const& name)
{
if (prefix.empty())
return make_gauge(name);
return make_gauge(prefix + "." + name);
return makeGauge(name);
return makeGauge(prefix + "." + name);
}
/** @} */
@@ -104,14 +104,14 @@ public:
*/
/** @{ */
virtual Meter
make_meter(std::string const& name) = 0;
makeMeter(std::string const& name) = 0;
Meter
make_meter(std::string const& prefix, std::string const& name)
makeMeter(std::string const& prefix, std::string const& name)
{
if (prefix.empty())
return make_meter(name);
return make_meter(prefix + "." + name);
return makeMeter(name);
return makeMeter(prefix + "." + name);
}
/** @} */
};

View File

@@ -29,7 +29,7 @@ public:
factory function in the Collector interface.
@see Collector.
*/
explicit Counter(std::shared_ptr<CounterImpl> const& impl) : m_impl(impl)
explicit Counter(std::shared_ptr<CounterImpl> const& impl) : m_impl_(impl)
{
}
@@ -38,8 +38,8 @@ public:
void
increment(value_type amount) const
{
if (m_impl)
m_impl->increment(amount);
if (m_impl_)
m_impl_->increment(amount);
}
Counter const&
@@ -85,7 +85,7 @@ public:
}
private:
std::shared_ptr<CounterImpl> m_impl;
std::shared_ptr<CounterImpl> m_impl_;
};
} // namespace beast::insight

View File

@@ -31,7 +31,7 @@ public:
factory function in the Collector interface.
@see Collector.
*/
explicit Event(std::shared_ptr<EventImpl> const& impl) : m_impl(impl)
explicit Event(std::shared_ptr<EventImpl> const& impl) : m_impl_(impl)
{
}
@@ -41,18 +41,18 @@ public:
notify(std::chrono::duration<Rep, Period> const& value) const
{
using namespace std::chrono;
if (m_impl)
m_impl->notify(ceil<value_type>(value));
if (m_impl_)
m_impl_->notify(ceil<value_type>(value));
}
[[nodiscard]] std::shared_ptr<EventImpl> const&
impl() const
{
return m_impl;
return m_impl_;
}
private:
std::shared_ptr<EventImpl> m_impl;
std::shared_ptr<EventImpl> m_impl_;
};
} // namespace beast::insight

View File

@@ -31,7 +31,7 @@ public:
factory function in the Collector interface.
@see Collector.
*/
explicit Gauge(std::shared_ptr<GaugeImpl> const& impl) : m_impl(impl)
explicit Gauge(std::shared_ptr<GaugeImpl> const& impl) : m_impl_(impl)
{
}
@@ -44,8 +44,8 @@ public:
void
set(value_type value) const
{
if (m_impl)
m_impl->set(value);
if (m_impl_)
m_impl_->set(value);
}
Gauge const&
@@ -61,8 +61,8 @@ public:
void
increment(difference_type amount) const
{
if (m_impl)
m_impl->increment(amount);
if (m_impl_)
m_impl_->increment(amount);
}
Gauge const&
@@ -111,11 +111,11 @@ public:
[[nodiscard]] std::shared_ptr<GaugeImpl> const&
impl() const
{
return m_impl;
return m_impl_;
}
private:
std::shared_ptr<GaugeImpl> m_impl;
std::shared_ptr<GaugeImpl> m_impl_;
};
} // namespace beast::insight

View File

@@ -20,18 +20,18 @@ public:
factory function in the Collector interface.
@see Collector.
*/
explicit Hook(std::shared_ptr<HookImpl> const& impl) : m_impl(impl)
explicit Hook(std::shared_ptr<HookImpl> const& impl) : m_impl_(impl)
{
}
[[nodiscard]] std::shared_ptr<HookImpl> const&
impl() const
{
return m_impl;
return m_impl_;
}
private:
std::shared_ptr<HookImpl> m_impl;
std::shared_ptr<HookImpl> m_impl_;
};
} // namespace beast::insight

View File

@@ -28,7 +28,7 @@ public:
factory function in the Collector interface.
@see Collector.
*/
explicit Meter(std::shared_ptr<MeterImpl> const& impl) : m_impl(impl)
explicit Meter(std::shared_ptr<MeterImpl> const& impl) : m_impl_(impl)
{
}
@@ -37,8 +37,8 @@ public:
void
increment(value_type amount) const
{
if (m_impl)
m_impl->increment(amount);
if (m_impl_)
m_impl_->increment(amount);
}
Meter const&
@@ -66,11 +66,11 @@ public:
[[nodiscard]] std::shared_ptr<MeterImpl> const&
impl() const
{
return m_impl;
return m_impl_;
}
private:
std::shared_ptr<MeterImpl> m_impl;
std::shared_ptr<MeterImpl> m_impl_;
};
} // namespace beast::insight

View File

@@ -95,7 +95,7 @@ struct hash<::beast::IP::Address>
std::size_t
operator()(::beast::IP::Address const& addr) const
{
return ::beast::uhash<>{}(addr);
return ::beast::Uhash<>{}(addr);
}
};
} // namespace boost

View File

@@ -27,56 +27,56 @@ public:
@return An optional endpoint; will be `std::nullopt` on failure
*/
static std::optional<Endpoint>
from_string_checked(std::string const& s);
fromStringChecked(std::string const& s);
static Endpoint
from_string(std::string const& s);
fromString(std::string const& s);
/** Returns a string representing the endpoint. */
[[nodiscard]] std::string
to_string() const;
toString() const;
/** Returns the port number on the endpoint. */
[[nodiscard]] Port
port() const
{
return m_port;
return m_port_;
}
/** Returns a new Endpoint with a different port. */
[[nodiscard]] Endpoint
at_port(Port port) const
atPort(Port port) const
{
return Endpoint(m_addr, port);
return Endpoint(m_addr_, port);
}
/** Returns the address portion of this endpoint. */
[[nodiscard]] Address const&
address() const
{
return m_addr;
return m_addr_;
}
/** Convenience accessors for the address part. */
/** @{ */
[[nodiscard]] bool
is_v4() const
isV4() const
{
return m_addr.is_v4();
return m_addr_.is_v4();
}
[[nodiscard]] bool
is_v6() const
isV6() const
{
return m_addr.is_v6();
return m_addr_.is_v6();
}
[[nodiscard]] AddressV4
to_v4() const
toV4() const
{
return m_addr.to_v4();
return m_addr_.to_v4();
}
[[nodiscard]] AddressV6
to_v6() const
toV6() const
{
return m_addr.to_v6();
return m_addr_.to_v6();
}
/** @} */
@@ -114,12 +114,12 @@ public:
hash_append(Hasher& h, Endpoint const& endpoint)
{
using ::beast::hash_append;
hash_append(h, endpoint.m_addr, endpoint.m_port);
hash_append(h, endpoint.m_addr_, endpoint.m_port_);
}
private:
Address m_addr;
Port m_port;
Address m_addr_;
Port m_port_;
};
//------------------------------------------------------------------------------
@@ -167,7 +167,7 @@ is_public(Endpoint const& endpoint)
inline std::string
to_string(Endpoint const& endpoint)
{
return endpoint.to_string();
return endpoint.toString();
}
/** Output stream conversion. */
@@ -197,7 +197,7 @@ struct hash<::beast::IP::Endpoint>
std::size_t
operator()(::beast::IP::Endpoint const& endpoint) const
{
return ::beast::uhash<>{}(endpoint);
return ::beast::Uhash<>{}(endpoint);
}
};
} // namespace std
@@ -212,7 +212,7 @@ struct hash<::beast::IP::Endpoint>
std::size_t
operator()(::beast::IP::Endpoint const& endpoint) const
{
return ::beast::uhash<>{}(endpoint);
return ::beast::Uhash<>{}(endpoint);
}
};
} // namespace boost

View File

@@ -11,31 +11,31 @@
namespace beast::unit_test {
/** Utility for producing nicely composed output of amounts with units. */
class amount
class Amount
{
private:
std::size_t n_;
std::string const& what_;
public:
amount(amount const&) = default;
amount&
operator=(amount const&) = delete;
Amount(Amount const&) = default;
Amount&
operator=(Amount const&) = delete;
template <class = void>
amount(std::size_t n, std::string const& what);
Amount(std::size_t n, std::string const& what);
friend std::ostream&
operator<<(std::ostream& s, amount const& t);
operator<<(std::ostream& s, Amount const& t);
};
template <class>
amount::amount(std::size_t n, std::string const& what) : n_(n), what_(what)
Amount::Amount(std::size_t n, std::string const& what) : n_(n), what_(what)
{
}
inline std::ostream&
operator<<(std::ostream& s, amount const& t)
operator<<(std::ostream& s, Amount const& t)
{
s << t.n_ << " " << t.what_ << ((t.n_ != 1) ? "s" : "");
return s;

View File

@@ -11,24 +11,24 @@ namespace beast::unit_test::detail {
provide additional behavior.
*/
template <class Container>
class const_container
class ConstContainer
{
private:
using cont_type = Container;
cont_type m_cont;
cont_type m_cont_;
protected:
cont_type&
cont()
{
return m_cont;
return m_cont_;
}
[[nodiscard]] cont_type const&
cont() const
{
return m_cont;
return m_cont_;
}
public:
@@ -42,14 +42,14 @@ public:
[[nodiscard]] bool
empty() const
{
return m_cont.empty();
return m_cont_.empty();
}
/** Returns the number of items in the container. */
[[nodiscard]] size_type
size() const
{
return m_cont.size();
return m_cont_.size();
}
/** Returns forward iterators for traversal. */
@@ -57,25 +57,25 @@ public:
[[nodiscard]] const_iterator
begin() const
{
return m_cont.cbegin();
return m_cont_.cbegin();
}
[[nodiscard]] const_iterator
cbegin() const
{
return m_cont.cbegin();
return m_cont_.cbegin();
}
[[nodiscard]] const_iterator
end() const
{
return m_cont.cend();
return m_cont_.cend();
}
[[nodiscard]] const_iterator
cend() const
{
return m_cont.cend();
return m_cont_.cend();
}
/** @} */
};

View File

@@ -11,11 +11,11 @@ namespace beast::unit_test {
namespace detail {
/// Holds test suites registered during static initialization.
inline suite_list&
inline SuiteList&
global_suites()
{
static suite_list s;
return s;
static SuiteList kS;
return kS;
}
template <class Suite>
@@ -35,7 +35,7 @@ struct insert_suite
} // namespace detail
/// Holds test suites registered during static initialization.
inline suite_list const&
inline SuiteList const&
global_suites()
{
return detail::global_suites();

View File

@@ -11,70 +11,70 @@
namespace beast::unit_test {
// Predicate for implementing matches
class selector
class Selector
{
public:
enum class mode_t {
enum class ModeT {
// Run all tests except manual ones
all,
All,
// Run tests that match in any field
automatch,
Automatch,
// Match on suite
suite,
Suite,
// Match on library
library,
Library,
// Match on module (used internally)
module,
Module,
// Match nothing (used internally)
none
None
};
private:
mode_t mode_;
ModeT mode_;
std::string pat_;
std::string library_;
public:
template <class = void>
explicit selector(mode_t mode, std::string const& pattern = "");
explicit Selector(ModeT mode, std::string const& pattern = "");
template <class = void>
bool
operator()(suite_info const& s);
operator()(SuiteInfo const& s);
};
//------------------------------------------------------------------------------
template <class>
selector::selector(mode_t mode, std::string const& pattern) : mode_(mode), pat_(pattern)
Selector::Selector(ModeT mode, std::string const& pattern) : mode_(mode), pat_(pattern)
{
if (mode_ == mode_t::automatch && pattern.empty())
mode_ = mode_t::all;
if (mode_ == ModeT::Automatch && pattern.empty())
mode_ = ModeT::All;
}
template <class>
bool
selector::operator()(suite_info const& s)
Selector::operator()(SuiteInfo const& s)
{
switch (mode_)
{
case mode_t::automatch:
case ModeT::Automatch:
// suite or full name
if (s.name() == pat_ || s.full_name() == pat_)
if (s.name() == pat_ || s.fullName() == pat_)
{
mode_ = mode_t::none;
mode_ = ModeT::None;
return true;
}
// check module
if (pat_ == s.module())
{
mode_ = mode_t::module;
mode_ = ModeT::Module;
library_ = s.library();
return !s.manual();
}
@@ -82,12 +82,12 @@ selector::operator()(suite_info const& s)
// check library
if (pat_ == s.library())
{
mode_ = mode_t::library;
mode_ = ModeT::Library;
return !s.manual();
}
// check start of name
if (s.name().starts_with(pat_) || s.full_name().starts_with(pat_))
if (s.name().starts_with(pat_) || s.fullName().starts_with(pat_))
{
// Don't change the mode so that the partial pattern can match
// more than once
@@ -96,19 +96,19 @@ selector::operator()(suite_info const& s)
return false;
case mode_t::suite:
case ModeT::Suite:
return pat_ == s.name();
case mode_t::module:
case ModeT::Module:
return pat_ == s.module() && !s.manual();
case mode_t::library:
case ModeT::Library:
return pat_ == s.library() && !s.manual();
case mode_t::none:
case ModeT::None:
return false;
case mode_t::all:
case ModeT::All:
default:
break;
};
@@ -135,31 +135,31 @@ selector::operator()(suite_info const& s)
not marked manual are selected from then on.
*/
inline selector
inline Selector
match_auto(std::string const& name)
{
return selector(selector::mode_t::automatch, name);
return Selector(Selector::ModeT::Automatch, name);
}
/** Return a predicate that matches all suites not marked manual. */
inline selector
inline Selector
match_all()
{
return selector(selector::mode_t::all);
return Selector(Selector::ModeT::All);
}
/** Returns a predicate that matches a specific suite. */
inline selector
inline Selector
match_suite(std::string const& name)
{
return selector(selector::mode_t::suite, name);
return Selector(Selector::ModeT::Suite, name);
}
/** Returns a predicate that matches all suites in a library. */
inline selector
inline Selector
match_library(std::string const& name)
{
return selector(selector::mode_t::library, name);
return Selector(Selector::ModeT::Library, name);
}
} // namespace beast::unit_test

View File

@@ -10,65 +10,65 @@
namespace beast::unit_test {
/** A test runner that stores the results. */
class recorder : public runner
class Recorder : public Runner
{
private:
results m_results;
suite_results m_suite;
case_results m_case;
Results m_results_;
SuiteResults m_suite_;
CaseResults m_case_;
public:
recorder() = default;
Recorder() = default;
/** Returns a report with the results of all completed suites. */
[[nodiscard]] results const&
[[nodiscard]] Results const&
report() const
{
return m_results;
return m_results_;
}
private:
void
on_suite_begin(suite_info const& info) override
onSuiteBegin(SuiteInfo const& info) override
{
m_suite = suite_results(info.full_name());
m_suite_ = SuiteResults(info.fullName());
}
void
on_suite_end() override
onSuiteEnd() override
{
m_results.insert(std::move(m_suite));
m_results_.insert(std::move(m_suite_));
}
void
on_case_begin(std::string const& name) override
onCaseBegin(std::string const& name) override
{
m_case = case_results(name);
m_case_ = CaseResults(name);
}
void
on_case_end() override
onCaseEnd() override
{
if (!m_case.tests.empty())
m_suite.insert(std::move(m_case));
if (!m_case_.tests.empty())
m_suite_.insert(std::move(m_case_));
}
void
on_pass() override
onPass() override
{
m_case.tests.pass();
m_case_.tests.pass();
}
void
on_fail(std::string const& reason) override
onFail(std::string const& reason) override
{
m_case.tests.fail(reason);
m_case_.tests.fail(reason);
}
void
on_log(std::string const& s) override
onLog(std::string const& s) override
{
m_case.log.insert(s);
m_case_.log.insert(s);
}
};

View File

@@ -26,23 +26,23 @@ namespace detail {
The totals are output when the object is destroyed.
*/
template <class = void>
class reporter : public runner
class Reporter : public Runner
{
private:
using clock_type = std::chrono::steady_clock;
struct case_results
struct CaseResults
{
std::string name;
std::size_t total = 0;
std::size_t failed = 0;
explicit case_results(std::string name_ = "") : name(std::move(name_))
explicit CaseResults(std::string name = "") : name(std::move(name))
{
}
};
struct suite_results
struct SuiteResults
{
std::string name;
std::size_t cases = 0;
@@ -50,21 +50,21 @@ private:
std::size_t failed = 0;
typename clock_type::time_point start = clock_type::now();
explicit suite_results(std::string name_ = "") : name(std::move(name_))
explicit SuiteResults(std::string name = "") : name(std::move(name))
{
}
void
add(case_results const& r);
add(CaseResults const& r);
};
struct results
struct Results
{
using run_time = std::pair<std::string, typename clock_type::duration>;
// Need to be named before converting
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
enum { max_top = 10 };
enum { MaxTop = 10 };
std::size_t suites = 0;
std::size_t cases = 0;
@@ -74,54 +74,54 @@ private:
typename clock_type::time_point start = clock_type::now();
void
add(suite_results const& r);
add(SuiteResults const& r);
};
std::ostream& os_;
results results_;
suite_results suite_results_;
case_results case_results_;
Results results_;
SuiteResults suite_results_;
CaseResults case_results_;
public:
reporter(reporter const&) = delete;
reporter&
operator=(reporter const&) = delete;
Reporter(Reporter const&) = delete;
Reporter&
operator=(Reporter const&) = delete;
~reporter() override;
~Reporter() override;
explicit reporter(std::ostream& os = std::cout);
explicit Reporter(std::ostream& os = std::cout);
private:
static std::string
fmtdur(typename clock_type::duration const& d);
void
on_suite_begin(suite_info const& info) override;
onSuiteBegin(SuiteInfo const& info) override;
void
on_suite_end() override;
onSuiteEnd() override;
void
on_case_begin(std::string const& name) override;
onCaseBegin(std::string const& name) override;
void
on_case_end() override;
onCaseEnd() override;
void
on_pass() override;
onPass() override;
void
on_fail(std::string const& reason) override;
onFail(std::string const& reason) override;
void
on_log(std::string const& s) override;
onLog(std::string const& s) override;
};
//------------------------------------------------------------------------------
template <class Unused>
void
reporter<Unused>::suite_results::add(case_results const& r)
Reporter<Unused>::SuiteResults::add(CaseResults const& r)
{
++cases;
total += r.total;
@@ -130,7 +130,7 @@ reporter<Unused>::suite_results::add(case_results const& r)
template <class Unused>
void
reporter<Unused>::results::add(suite_results const& r)
Reporter<Unused>::Results::add(SuiteResults const& r)
{
++suites;
total += r.total;
@@ -148,11 +148,11 @@ reporter<Unused>::results::add(suite_results const& r)
});
if (iter != top.end())
{
if (top.size() == max_top)
if (top.size() == MaxTop)
top.resize(top.size() - 1);
top.emplace(iter, r.name, elapsed);
}
else if (top.size() < max_top)
else if (top.size() < MaxTop)
{
top.emplace_back(r.name, elapsed);
}
@@ -162,12 +162,12 @@ reporter<Unused>::results::add(suite_results const& r)
//------------------------------------------------------------------------------
template <class Unused>
reporter<Unused>::reporter(std::ostream& os) : os_(os)
Reporter<Unused>::Reporter(std::ostream& os) : os_(os)
{
}
template <class Unused>
reporter<Unused>::~reporter()
Reporter<Unused>::~Reporter()
{
if (results_.top.size() > 0)
{
@@ -176,14 +176,14 @@ reporter<Unused>::~reporter()
os_ << std::setw(8) << fmtdur(i.second) << " " << i.first << '\n';
}
auto const elapsed = clock_type::now() - results_.start;
os_ << fmtdur(elapsed) << ", " << amount{results_.suites, "suite"} << ", "
<< amount{results_.cases, "case"} << ", " << amount{results_.total, "test"} << " total, "
<< amount{results_.failed, "failure"} << std::endl;
os_ << fmtdur(elapsed) << ", " << Amount{results_.suites, "suite"} << ", "
<< Amount{results_.cases, "case"} << ", " << Amount{results_.total, "test"} << " total, "
<< Amount{results_.failed, "failure"} << std::endl;
}
template <class Unused>
std::string
reporter<Unused>::fmtdur(typename clock_type::duration const& d)
Reporter<Unused>::fmtdur(typename clock_type::duration const& d)
{
using namespace std::chrono;
auto const ms = duration_cast<milliseconds>(d);
@@ -196,44 +196,44 @@ reporter<Unused>::fmtdur(typename clock_type::duration const& d)
template <class Unused>
void
reporter<Unused>::on_suite_begin(suite_info const& info)
Reporter<Unused>::on_suite_begin(SuiteInfo const& info)
{
suite_results_ = suite_results{info.full_name()};
suite_results_ = SuiteResults{info.fullName()};
}
template <class Unused>
void
reporter<Unused>::on_suite_end()
Reporter<Unused>::on_suite_end()
{
results_.add(suite_results_);
}
template <class Unused>
void
reporter<Unused>::on_case_begin(std::string const& name)
Reporter<Unused>::on_case_begin(std::string const& name)
{
case_results_ = case_results(name);
case_results_ = CaseResults(name);
os_ << suite_results_.name << (case_results_.name.empty() ? "" : (" " + case_results_.name))
<< std::endl;
}
template <class Unused>
void
reporter<Unused>::on_case_end()
Reporter<Unused>::on_case_end()
{
suite_results_.add(case_results_);
}
template <class Unused>
void
reporter<Unused>::on_pass()
Reporter<Unused>::on_pass()
{
++case_results_.total;
}
template <class Unused>
void
reporter<Unused>::on_fail(std::string const& reason)
Reporter<Unused>::on_fail(std::string const& reason)
{
++case_results_.failed;
++case_results_.total;
@@ -243,13 +243,13 @@ reporter<Unused>::on_fail(std::string const& reason)
template <class Unused>
void
reporter<Unused>::on_log(std::string const& s)
Reporter<Unused>::on_log(std::string const& s)
{
os_ << s;
}
} // namespace detail
using reporter = detail::reporter<>;
using reporter = detail::Reporter<>;
} // namespace beast::unit_test

View File

@@ -13,17 +13,17 @@
namespace beast::unit_test {
/** Holds a set of test condition outcomes in a testcase. */
class case_results
class CaseResults
{
public:
/** Holds the result of evaluating one test condition. */
struct test
struct Test
{
explicit test(bool pass_) : pass(pass_)
explicit Test(bool pass) : pass(pass)
{
}
test(bool pass_, std::string reason_) : pass(pass_), reason(std::move(reason_))
Test(bool pass, std::string reason) : pass(pass), reason(std::move(reason))
{
}
@@ -32,13 +32,13 @@ public:
};
private:
class tests_t : public detail::const_container<std::vector<test>>
class TestsT : public detail::ConstContainer<std::vector<Test>>
{
private:
std::size_t failed_{0};
public:
tests_t() = default;
TestsT() = default;
/** Returns the total number of test conditions. */
[[nodiscard]] std::size_t
@@ -70,7 +70,7 @@ private:
}
};
class log_t : public detail::const_container<std::vector<std::string>>
class LogT : public detail::ConstContainer<std::vector<std::string>>
{
public:
/** Insert a string into the log. */
@@ -84,7 +84,7 @@ private:
std::string name_;
public:
explicit case_results(std::string name = "") : name_(std::move(name))
explicit CaseResults(std::string name = "") : name_(std::move(name))
{
}
@@ -96,16 +96,16 @@ public:
}
/** Memberspace for a container of test condition outcomes. */
tests_t tests;
TestsT tests;
/** Memberspace for a container of testcase log messages. */
log_t log;
LogT log;
};
//--------------------------------------------------------------------------
/** Holds the set of testcase results in a suite. */
class suite_results : public detail::const_container<std::vector<case_results>>
class SuiteResults : public detail::ConstContainer<std::vector<CaseResults>>
{
private:
std::string name_;
@@ -113,7 +113,7 @@ private:
std::size_t failed_ = 0;
public:
explicit suite_results(std::string name = "") : name_(std::move(name))
explicit SuiteResults(std::string name = "") : name_(std::move(name))
{
}
@@ -141,7 +141,7 @@ public:
/** Insert a set of testcase results. */
/** @{ */
void
insert(case_results&& r)
insert(CaseResults&& r)
{
total_ += r.tests.total();
failed_ += r.tests.failed();
@@ -149,7 +149,7 @@ public:
}
void
insert(case_results const& r)
insert(CaseResults const& r)
{
cont().push_back(r);
total_ += r.tests.total();
@@ -162,21 +162,21 @@ public:
// VFALCO TODO Make this a template class using scoped allocators
/** Holds the results of running a set of testsuites. */
class results : public detail::const_container<std::vector<suite_results>>
class Results : public detail::ConstContainer<std::vector<SuiteResults>>
{
private:
std::size_t m_cases{0};
std::size_t m_cases_{0};
std::size_t total_{0};
std::size_t failed_{0};
public:
results() = default;
Results() = default;
/** Returns the total number of test cases. */
[[nodiscard]] std::size_t
cases() const
{
return m_cases;
return m_cases_;
}
/** Returns the total number of test conditions. */
@@ -196,18 +196,18 @@ public:
/** Insert a set of suite results. */
/** @{ */
void
insert(suite_results&& r)
insert(SuiteResults&& r)
{
m_cases += r.size();
m_cases_ += r.size();
total_ += r.total();
failed_ += r.failed();
cont().emplace_back(std::move(r));
}
void
insert(suite_results const& r)
insert(SuiteResults const& r)
{
m_cases += r.size();
m_cases_ += r.size();
total_ += r.total();
failed_ += r.failed();
cont().push_back(r);

View File

@@ -18,7 +18,7 @@ namespace beast::unit_test {
Derived classes can customize the reporting behavior. This interface is
injected into the unit_test class to receive the results of the tests.
*/
class runner
class Runner
{
std::string arg_;
bool default_ = false;
@@ -27,11 +27,11 @@ class runner
std::recursive_mutex mutex_;
public:
runner() = default;
virtual ~runner() = default;
runner(runner const&) = delete;
runner&
operator=(runner const&) = delete;
Runner() = default;
virtual ~Runner() = default;
Runner(Runner const&) = delete;
Runner&
operator=(Runner const&) = delete;
/** Set the argument string.
@@ -58,7 +58,7 @@ public:
*/
template <class = void>
bool
run(suite_info const& s);
run(SuiteInfo const& s);
/** Run a sequence of suites.
The expression
@@ -79,14 +79,14 @@ public:
*/
template <class FwdIter, class Pred>
bool
run_if(FwdIter first, FwdIter last, Pred pred = Pred{});
runIf(FwdIter first, FwdIter last, Pred pred = Pred{});
/** Run all suites in a container.
@return `true` if any conditions failed.
*/
template <class SequenceContainer>
bool
run_each(SequenceContainer const& c);
runEach(SequenceContainer const& c);
/** Conditionally run suites in a container.
pred will be called as:
@@ -97,53 +97,53 @@ public:
*/
template <class SequenceContainer, class Pred>
bool
run_each_if(SequenceContainer const& c, Pred pred = Pred{});
runEachIf(SequenceContainer const& c, Pred pred = Pred{});
protected:
/// Called when a new suite starts.
virtual void
on_suite_begin(suite_info const&)
onSuiteBegin(SuiteInfo const&)
{
}
/// Called when a suite ends.
virtual void
on_suite_end()
onSuiteEnd()
{
}
/// Called when a new case starts.
virtual void
on_case_begin(std::string const&)
onCaseBegin(std::string const&)
{
}
/// Called when a new case ends.
virtual void
on_case_end()
onCaseEnd()
{
}
/// Called for each passing condition.
virtual void
on_pass()
onPass()
{
}
/// Called for each failing condition.
virtual void
on_fail(std::string const&)
onFail(std::string const&)
{
}
/// Called when a test logs output.
virtual void
on_log(std::string const&)
onLog(std::string const&)
{
}
private:
friend class suite;
friend class Suite;
// Start a new testcase.
template <class = void>
@@ -167,23 +167,23 @@ private:
template <class>
bool
runner::run(suite_info const& s)
Runner::run(SuiteInfo const& s)
{
// Enable 'default' testcase
default_ = true;
failed_ = false;
on_suite_begin(s);
onSuiteBegin(s);
s.run(*this);
// Forgot to call pass or fail.
BOOST_ASSERT(cond_);
on_case_end();
on_suite_end();
onCaseEnd();
onSuiteEnd();
return failed_;
}
template <class FwdIter>
bool
runner::run(FwdIter first, FwdIter last)
Runner::run(FwdIter first, FwdIter last)
{
bool failed(false);
for (; first != last; ++first)
@@ -193,7 +193,7 @@ runner::run(FwdIter first, FwdIter last)
template <class FwdIter, class Pred>
bool
runner::run_if(FwdIter first, FwdIter last, Pred pred)
Runner::runIf(FwdIter first, FwdIter last, Pred pred)
{
bool failed(false);
for (; first != last; ++first)
@@ -206,7 +206,7 @@ runner::run_if(FwdIter first, FwdIter last, Pred pred)
template <class SequenceContainer>
bool
runner::run_each(SequenceContainer const& c)
Runner::runEach(SequenceContainer const& c)
{
bool failed(false);
for (auto const& s : c)
@@ -216,7 +216,7 @@ runner::run_each(SequenceContainer const& c)
template <class SequenceContainer, class Pred>
bool
runner::run_each_if(SequenceContainer const& c, Pred pred)
Runner::runEachIf(SequenceContainer const& c, Pred pred)
{
bool failed(false);
for (auto const& s : c)
@@ -229,7 +229,7 @@ runner::run_each_if(SequenceContainer const& c, Pred pred)
template <class>
void
runner::testcase(std::string const& name)
Runner::testcase(std::string const& name)
{
std::scoped_lock const lock(mutex_);
// Name may not be empty
@@ -237,43 +237,43 @@ runner::testcase(std::string const& name)
// Forgot to call pass or fail
BOOST_ASSERT(default_ || cond_);
if (!default_)
on_case_end();
onCaseEnd();
default_ = false;
cond_ = false;
on_case_begin(name);
onCaseBegin(name);
}
template <class>
void
runner::pass()
Runner::pass()
{
std::scoped_lock const lock(mutex_);
if (default_)
testcase("");
on_pass();
onPass();
cond_ = true;
}
template <class>
void
runner::fail(std::string const& reason)
Runner::fail(std::string const& reason)
{
std::scoped_lock const lock(mutex_);
if (default_)
testcase("");
on_fail(reason);
onFail(reason);
failed_ = true;
cond_ = true;
}
template <class>
void
runner::log(std::string const& s)
Runner::log(std::string const& s)
{
std::scoped_lock const lock(mutex_);
if (default_)
testcase("");
on_log(s);
onLog(s);
}
} // namespace beast::unit_test

View File

@@ -20,7 +20,7 @@ namespace detail {
template <class String>
static std::string
make_reason(String const& reason, char const* file, int line)
makeReason(String const& reason, char const* file, int line)
{
std::string s(reason);
if (!s.empty())
@@ -37,7 +37,7 @@ make_reason(String const& reason, char const* file, int line)
class Thread;
enum class abort_t { no_abort_on_fail, abort_on_fail };
enum class AbortT { NoAbortOnFail, AbortOnFail };
/** A testsuite class.
@@ -46,16 +46,16 @@ enum class abort_t { no_abort_on_fail, abort_on_fail };
derive from it and use the BEAST_DEFINE_UNIT_TEST macro in a
translation unit.
*/
class suite
class Suite
{
private:
bool abort_ = false;
bool aborted_ = false;
runner* runner_ = nullptr;
Runner* runner_ = nullptr;
// This exception is thrown internally to stop the current suite
// in the event of a failure, if the option to stop is set.
struct abort_exception : public std::exception
struct AbortException : public std::exception
{
[[nodiscard]] char const*
what() const noexcept override
@@ -65,16 +65,16 @@ private:
};
template <class CharT, class Traits, class Allocator>
class log_buf : public std::basic_stringbuf<CharT, Traits, Allocator>
class LogBuf : public std::basic_stringbuf<CharT, Traits, Allocator>
{
suite& suite_;
Suite& suite_;
public:
explicit log_buf(suite& self) : suite_(self)
explicit LogBuf(Suite& self) : suite_(self)
{
}
~log_buf() override
~LogBuf() override
{
sync();
}
@@ -94,25 +94,25 @@ private:
class CharT,
class Traits = std::char_traits<CharT>,
class Allocator = std::allocator<CharT>>
class log_os : public std::basic_ostream<CharT, Traits>
class LogOs : public std::basic_ostream<CharT, Traits>
{
log_buf<CharT, Traits, Allocator> buf_;
LogBuf<CharT, Traits, Allocator> buf_;
public:
explicit log_os(suite& self) : std::basic_ostream<CharT, Traits>(&buf_), buf_(self)
explicit LogOs(Suite& self) : std::basic_ostream<CharT, Traits>(&buf_), buf_(self)
{
}
};
class scoped_testcase;
class ScopedTestcase;
class testcase_t
class TestcaseT
{
suite& suite_;
Suite& suite_;
std::stringstream ss_;
public:
explicit testcase_t(suite& self) : suite_(self)
explicit TestcaseT(Suite& self) : suite_(self)
{
}
@@ -127,13 +127,13 @@ private:
@param abort Determines if suite continues running after a failure.
*/
void
operator()(std::string const& name, abort_t abort = abort_t::no_abort_on_fail);
operator()(std::string const& name, AbortT abort = AbortT::NoAbortOnFail);
scoped_testcase
operator()(abort_t abort);
ScopedTestcase
operator()(AbortT abort);
template <class T>
scoped_testcase
ScopedTestcase
operator<<(T const& t);
};
@@ -143,28 +143,28 @@ public:
Text sent to the log output stream will be forwarded to
the output stream associated with the runner.
*/
log_os<char> log;
LogOs<char> log;
/** Memberspace for declaring test cases. */
testcase_t testcase;
TestcaseT testcase;
/** Returns the "current" running suite.
If no suite is running, nullptr is returned.
*/
static suite*
this_suite()
static Suite*
thisSuite()
{
return *p_this_suite();
return *pThisSuite();
}
suite() : log(*this), testcase(*this)
Suite() : log(*this), testcase(*this)
{
}
virtual ~suite() = default;
suite(suite const&) = delete;
suite&
operator=(suite const&) = delete;
virtual ~Suite() = default;
Suite(Suite const&) = delete;
Suite&
operator=(Suite const&) = delete;
/** Invokes the test using the specified runner.
@@ -175,7 +175,7 @@ public:
*/
template <class = void>
void
operator()(runner& r);
operator()(Runner& r);
/** Record a successful test condition. */
template <class = void>
@@ -296,11 +296,11 @@ public:
private:
friend class Thread;
static suite**
p_this_suite()
static Suite**
pThisSuite()
{
static suite* pts = nullptr; // NOLINT(misc-const-correctness)
return &pts;
static Suite* kPTS = nullptr; // NOLINT(misc-const-correctness)
return &kPTS;
}
/** Runs the suite. */
@@ -308,41 +308,41 @@ private:
run() = 0;
void
propagate_abort() const;
propagateAbort() const;
template <class = void>
void
run(runner& r);
run(Runner& r);
};
//------------------------------------------------------------------------------
// Helper for streaming testcase names
class suite::scoped_testcase
class Suite::ScopedTestcase
{
private:
suite& suite_;
Suite& suite_;
std::stringstream& ss_;
public:
scoped_testcase&
operator=(scoped_testcase const&) = delete;
ScopedTestcase&
operator=(ScopedTestcase const&) = delete;
~scoped_testcase()
~ScopedTestcase()
{
auto const& name = ss_.str();
if (!name.empty())
suite_.runner_->testcase(name);
}
scoped_testcase(suite& self, std::stringstream& ss) : suite_(self), ss_(ss)
ScopedTestcase(Suite& self, std::stringstream& ss) : suite_(self), ss_(ss)
{
ss_.clear();
ss_.str({});
}
template <class T>
scoped_testcase(suite& self, std::stringstream& ss, T const& t) : suite_(self), ss_(ss)
ScopedTestcase(Suite& self, std::stringstream& ss, T const& t) : suite_(self), ss_(ss)
{
ss_.clear();
ss_.str({});
@@ -350,7 +350,7 @@ public:
}
template <class T>
scoped_testcase&
ScopedTestcase&
operator<<(T const& t)
{
ss_ << t;
@@ -361,22 +361,22 @@ public:
//------------------------------------------------------------------------------
inline void
suite::testcase_t::operator()(std::string const& name, abort_t abort)
Suite::TestcaseT::operator()(std::string const& name, AbortT abort)
{
suite_.abort_ = abort == abort_t::abort_on_fail;
suite_.abort_ = abort == AbortT::AbortOnFail;
suite_.runner_->testcase(name);
}
inline suite::scoped_testcase
suite::testcase_t::operator()(abort_t abort)
inline Suite::ScopedTestcase
Suite::TestcaseT::operator()(AbortT abort)
{
suite_.abort_ = abort == abort_t::abort_on_fail;
suite_.abort_ = abort == AbortT::AbortOnFail;
return {suite_, ss_};
}
template <class T>
inline suite::scoped_testcase
suite::testcase_t::operator<<(T const& t)
inline Suite::ScopedTestcase
Suite::TestcaseT::operator<<(T const& t)
{
return {suite_, ss_, t};
}
@@ -385,24 +385,24 @@ suite::testcase_t::operator<<(T const& t)
template <class>
void
suite::operator()(runner& r)
Suite::operator()(Runner& r)
{
*p_this_suite() = this;
*pThisSuite() = this;
try
{
run(r);
*p_this_suite() = nullptr;
*pThisSuite() = nullptr;
}
catch (...)
{
*p_this_suite() = nullptr;
*pThisSuite() = nullptr;
throw;
}
}
template <class Condition, class String>
bool
suite::expect(Condition const& shouldBeTrue, String const& reason)
Suite::expect(Condition const& shouldBeTrue, String const& reason)
{
if (shouldBeTrue)
{
@@ -415,14 +415,14 @@ suite::expect(Condition const& shouldBeTrue, String const& reason)
template <class Condition, class String>
bool
suite::expect(Condition const& shouldBeTrue, String const& reason, char const* file, int line)
Suite::expect(Condition const& shouldBeTrue, String const& reason, char const* file, int line)
{
if (shouldBeTrue)
{
pass();
return true;
}
fail(detail::make_reason(reason, file, line));
fail(detail::makeReason(reason, file, line));
return false;
}
@@ -430,7 +430,7 @@ suite::expect(Condition const& shouldBeTrue, String const& reason, char const* f
template <class F, class String>
bool
suite::except(F&& f, String const& reason)
Suite::except(F&& f, String const& reason)
{
try
{
@@ -447,7 +447,7 @@ suite::except(F&& f, String const& reason)
template <class E, class F, class String>
bool
suite::except(F&& f, String const& reason)
Suite::except(F&& f, String const& reason)
{
try
{
@@ -464,7 +464,7 @@ suite::except(F&& f, String const& reason)
template <class F, class String>
bool
suite::unexcept(F&& f, String const& reason)
Suite::unexcept(F&& f, String const& reason)
{
try
{
@@ -481,7 +481,7 @@ suite::unexcept(F&& f, String const& reason)
template <class Condition, class String>
bool
suite::unexpected(Condition shouldBeFalse, String const& reason)
Suite::unexpected(Condition shouldBeFalse, String const& reason)
{
bool const b = static_cast<bool>(shouldBeFalse);
if (!b)
@@ -497,43 +497,43 @@ suite::unexpected(Condition shouldBeFalse, String const& reason)
template <class>
void
suite::pass()
Suite::pass()
{
propagate_abort();
propagateAbort();
runner_->pass();
}
// ::fail
template <class>
void
suite::fail(std::string const& reason)
Suite::fail(std::string const& reason)
{
propagate_abort();
propagateAbort();
runner_->fail(reason);
if (abort_)
{
aborted_ = true;
BOOST_THROW_EXCEPTION(abort_exception());
BOOST_THROW_EXCEPTION(AbortException());
}
}
template <class String>
void
suite::fail(String const& reason, char const* file, int line)
Suite::fail(String const& reason, char const* file, int line)
{
fail(detail::make_reason(reason, file, line));
fail(detail::makeReason(reason, file, line));
}
inline void
suite::propagate_abort() const
Suite::propagateAbort() const
{
if (abort_ && aborted_)
BOOST_THROW_EXCEPTION(abort_exception());
BOOST_THROW_EXCEPTION(AbortException());
}
template <class>
void
suite::run(runner& r)
Suite::run(Runner& r)
{
runner_ = &r;
@@ -541,7 +541,7 @@ suite::run(runner& r)
{
run();
}
catch (abort_exception const&) // NOLINT(bugprone-empty-catch)
catch (AbortException const&) // NOLINT(bugprone-empty-catch)
{
// ends the suite
}

View File

@@ -11,12 +11,12 @@
namespace beast::unit_test {
class runner;
class Runner;
/** Associates a unit test type with metadata. */
class suite_info
class SuiteInfo
{
using run_type = std::function<void(runner&)>;
using run_type = std::function<void(Runner&)>;
std::string name_;
std::string module_;
@@ -26,7 +26,7 @@ class suite_info
run_type run_;
public:
suite_info(
SuiteInfo(
std::string name,
std::string module,
std::string library,
@@ -69,20 +69,20 @@ public:
/// Return the canonical suite name as a string.
[[nodiscard]] std::string
full_name() const
fullName() const
{
return library_ + "." + module_ + "." + name_;
}
/// Run a new instance of the associated test suite.
void
run(runner& r) const
run(Runner& r) const
{
run_(r);
}
friend bool
operator<(suite_info const& lhs, suite_info const& rhs)
operator<(SuiteInfo const& lhs, SuiteInfo const& rhs)
{
// we want higher priority suites sorted first, thus the negation
// of priority value here
@@ -95,7 +95,7 @@ public:
/// Convenience for producing suite_info for a given test type.
template <class Suite>
suite_info
SuiteInfo
make_suite_info(
std::string name,
std::string module,
@@ -103,8 +103,8 @@ make_suite_info(
bool manual,
int priority)
{
return suite_info(
std::move(name), std::move(module), std::move(library), manual, priority, [](runner& r) {
return SuiteInfo(
std::move(name), std::move(module), std::move(library), manual, priority, [](Runner& r) {
Suite{}(r);
});
}

View File

@@ -16,7 +16,7 @@
namespace beast::unit_test {
/// A container of test suites.
class suite_list : public detail::const_container<std::set<suite_info>>
class SuiteList : public detail::ConstContainer<std::set<SuiteInfo>>
{
private:
#ifndef NDEBUG
@@ -38,7 +38,7 @@ public:
template <class Suite>
void
suite_list::insert(
SuiteList::insert(
char const* name,
char const* module,
char const* library,

View File

@@ -12,17 +12,17 @@ namespace severities {
// Hundreds of usages via logging macros
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
enum Severity {
kAll = 0,
KAll = 0,
kTrace = kAll,
kDebug = 1,
kInfo = 2,
kWarning = 3,
kError = 4,
kFatal = 5,
KTrace = KAll,
KDebug = 1,
KInfo = 2,
KWarning = 3,
KError = 4,
KFatal = 5,
kDisabled = 6,
kNone = kDisabled
KDisabled = 6,
KNone = KDisabled
};
} // namespace severities
@@ -48,7 +48,7 @@ private:
using Severity = severities::Severity;
// Invariant: m_sink always points to a valid Sink
Sink* m_sink;
Sink* m_sink_;
public:
//--------------------------------------------------------------------------
@@ -108,7 +108,7 @@ public:
private:
Severity thresh_;
bool m_console;
bool m_console_;
};
#ifndef __INTELLISENSE__
@@ -132,7 +132,7 @@ public:
class ScopedStream
{
public:
ScopedStream(ScopedStream const& other) : ScopedStream(other.m_sink, other.m_level)
ScopedStream(ScopedStream const& other) : ScopedStream(other.m_sink_, other.m_level_)
{
}
@@ -151,7 +151,7 @@ public:
std::ostringstream&
ostream() const
{
return m_ostream;
return m_ostream_;
}
std::ostream&
@@ -162,9 +162,9 @@ public:
operator<<(T const& t) const;
private:
Sink& m_sink;
Severity const m_level;
std::ostringstream mutable m_ostream;
Sink& m_sink_;
Severity const m_level_;
std::ostringstream mutable m_ostream_;
};
#ifndef __INTELLISENSE__
@@ -183,7 +183,7 @@ public:
{
public:
/** Create a stream which produces no output. */
explicit Stream() : m_sink(getNullSink()), m_level(severities::kDisabled)
explicit Stream() : m_sink_(getNullSink()), m_level_(severities::KDisabled)
{
}
@@ -191,14 +191,14 @@ public:
Constructor is inlined so checking active() very inexpensive.
*/
Stream(Sink& sink, Severity level) : m_sink(sink), m_level(level)
Stream(Sink& sink, Severity level) : m_sink_(sink), m_level_(level)
{
XRPL_ASSERT(
m_level < severities::kDisabled, "beast::Journal::Stream::Stream : maximum level");
m_level_ < severities::KDisabled, "beast::Journal::Stream::Stream : maximum level");
}
/** Construct or copy another Stream. */
Stream(Stream const& other) : Stream(other.m_sink, other.m_level)
Stream(Stream const& other) : Stream(other.m_sink_, other.m_level_)
{
}
@@ -209,14 +209,14 @@ public:
[[nodiscard]] Sink&
sink() const
{
return m_sink;
return m_sink_;
}
/** Returns the Severity level of messages this Stream reports. */
[[nodiscard]] Severity
level() const
{
return m_level;
return m_level_;
}
/** Returns `true` if sink logs anything at this stream's level. */
@@ -224,7 +224,7 @@ public:
[[nodiscard]] bool
active() const
{
return m_sink.active(m_level);
return m_sink_.active(m_level_);
}
explicit
@@ -245,8 +245,8 @@ public:
/** @} */
private:
Sink& m_sink;
Severity m_level;
Sink& m_sink_;
Severity m_level_;
};
#ifndef __INTELLISENSE__
@@ -264,7 +264,7 @@ public:
Journal() = delete;
/** Create a journal that writes to the specified sink. */
explicit Journal(Sink& sink) : m_sink(&sink)
explicit Journal(Sink& sink) : m_sink_(&sink)
{
}
@@ -272,14 +272,14 @@ public:
[[nodiscard]] Sink&
sink() const
{
return *m_sink;
return *m_sink_;
}
/** Returns a stream for this sink, with the specified severity level. */
[[nodiscard]] Stream
stream(Severity level) const
{
return Stream(*m_sink, level);
return Stream(*m_sink_, level);
}
/** Returns `true` if any message would be logged at this severity level.
@@ -289,7 +289,7 @@ public:
[[nodiscard]] bool
active(Severity level) const
{
return m_sink->active(level);
return m_sink_->active(level);
}
/** Severity stream access functions. */
@@ -297,37 +297,37 @@ public:
[[nodiscard]] Stream
trace() const
{
return {*m_sink, severities::kTrace};
return {*m_sink_, severities::KTrace};
}
[[nodiscard]] Stream
debug() const
{
return {*m_sink, severities::kDebug};
return {*m_sink_, severities::KDebug};
}
[[nodiscard]] Stream
info() const
{
return {*m_sink, severities::kInfo};
return {*m_sink_, severities::KInfo};
}
[[nodiscard]] Stream
warn() const
{
return {*m_sink, severities::kWarning};
return {*m_sink_, severities::KWarning};
}
[[nodiscard]] Stream
error() const
{
return {*m_sink, severities::kError};
return {*m_sink_, severities::KError};
}
[[nodiscard]] Stream
fatal() const
{
return {*m_sink, severities::kFatal};
return {*m_sink_, severities::KFatal};
}
/** @} */
};
@@ -347,15 +347,15 @@ template <typename T>
Journal::ScopedStream::ScopedStream(Journal::Stream const& stream, T const& t)
: ScopedStream(stream.sink(), stream.level())
{
m_ostream << t;
m_ostream_ << t;
}
template <typename T>
std::ostream&
Journal::ScopedStream::operator<<(T const& t) const
{
m_ostream << t;
return m_ostream;
m_ostream_ << t;
return m_ostream_;
}
//------------------------------------------------------------------------------
@@ -370,7 +370,7 @@ Journal::Stream::operator<<(T const& t) const
namespace detail {
template <class CharT, class Traits = std::char_traits<CharT>>
class logstream_buf : public std::basic_stringbuf<CharT, Traits>
class LogstreamBuf : public std::basic_stringbuf<CharT, Traits>
{
beast::Journal::Stream strm_;
@@ -389,11 +389,11 @@ class logstream_buf : public std::basic_stringbuf<CharT, Traits>
}
public:
explicit logstream_buf(beast::Journal::Stream const& strm) : strm_(strm)
explicit LogstreamBuf(beast::Journal::Stream const& strm) : strm_(strm)
{
}
~logstream_buf() override
~LogstreamBuf() override
{
sync();
}
@@ -414,7 +414,7 @@ public:
} // namespace detail
template <class CharT, class Traits = std::char_traits<CharT>>
class basic_logstream : public std::basic_ostream<CharT, Traits>
class BasicLogstream : public std::basic_ostream<CharT, Traits>
{
using char_type = CharT;
using traits_type = Traits;
@@ -422,16 +422,16 @@ class basic_logstream : public std::basic_ostream<CharT, Traits>
using pos_type = typename traits_type::pos_type;
using off_type = typename traits_type::off_type;
detail::logstream_buf<CharT, Traits> buf_;
detail::LogstreamBuf<CharT, Traits> buf_;
public:
explicit basic_logstream(beast::Journal::Stream const& strm)
explicit BasicLogstream(beast::Journal::Stream const& strm)
: std::basic_ostream<CharT, Traits>(&buf_), buf_(strm)
{
}
};
using logstream = basic_logstream<char>;
using logwstream = basic_logstream<wchar_t>;
using logstream = BasicLogstream<char>;
using logwstream = BasicLogstream<wchar_t>;
} // namespace beast

View File

@@ -23,11 +23,11 @@ public:
protected:
virtual void
map_begin() = 0;
mapBegin() = 0;
virtual void
map_begin(std::string const& key) = 0;
mapBegin(std::string const& key) = 0;
virtual void
map_end() = 0;
mapEnd() = 0;
virtual void
add(std::string const& key, std::string const& value) = 0;
@@ -40,7 +40,7 @@ protected:
template <typename Value>
void
lexical_add(std::string const& key, Value value)
lexicalAdd(std::string const& key, Value value)
{
std::stringstream ss;
ss << value;
@@ -79,11 +79,11 @@ protected:
add(std::string const& key, long double value);
virtual void
array_begin() = 0;
arrayBegin() = 0;
virtual void
array_begin(std::string const& key) = 0;
arrayBegin(std::string const& key) = 0;
virtual void
array_end() = 0;
arrayEnd() = 0;
virtual void
add(std::string const& value) = 0;
@@ -96,7 +96,7 @@ protected:
template <typename Value>
void
lexical_add(Value value)
lexicalAdd(Value value)
{
std::stringstream ss;
ss << value;
@@ -157,7 +157,7 @@ public:
operator*() const;
private:
Source* m_source;
Source* m_source_;
};
//------------------------------------------------------------------------------
@@ -169,9 +169,9 @@ private:
class PropertyStream::Proxy
{
private:
Map const* m_map;
std::string m_key;
std::ostringstream mutable m_ostream;
Map const* m_map_;
std::string m_key_;
std::ostringstream mutable m_ostream_;
public:
Proxy(Map const& map, std::string key);
@@ -189,7 +189,7 @@ public:
std::ostream&
operator<<(T const& t) const
{
return m_ostream << t;
return m_ostream_ << t;
}
};
@@ -202,7 +202,7 @@ public:
class PropertyStream::Map
{
private:
PropertyStream& m_stream;
PropertyStream& m_stream_;
public:
explicit Map(PropertyStream& stream);
@@ -224,7 +224,7 @@ public:
void
add(std::string const& key, Value value) const
{
m_stream.add(key, value);
m_stream_.add(key, value);
}
template <typename Key, typename Value>
@@ -261,7 +261,7 @@ template <typename Value>
PropertyStream::Proxy&
PropertyStream::Proxy::operator=(Value value)
{
m_map->add(m_key, value);
m_map_->add(m_key_, value);
return *this;
}
@@ -274,7 +274,7 @@ PropertyStream::Proxy::operator=(Value value)
class PropertyStream::Set
{
private:
PropertyStream& m_stream;
PropertyStream& m_stream_;
public:
Set(std::string const& key, Map& map);
@@ -294,7 +294,7 @@ public:
void
add(Value value) const
{
m_stream.add(value);
m_stream_.add(value);
}
};
@@ -308,7 +308,7 @@ public:
class PropertyStream::Source
{
private:
std::string const m_name;
std::string const m_name_;
std::recursive_mutex lock_;
Item item_;
Source* parent_{nullptr};
@@ -351,7 +351,7 @@ public:
/** Write only this Source to the stream. */
void
write_one(PropertyStream& stream);
writeOne(PropertyStream& stream);
/** write this source and all its children recursively to the stream. */
void
@@ -384,18 +384,18 @@ public:
find(std::string path);
Source*
find_one_deep(std::string const& name);
findOneDeep(std::string const& name);
PropertyStream::Source*
find_path(std::string path);
findPath(std::string path);
PropertyStream::Source*
find_one(std::string const& name);
findOne(std::string const& name);
static bool
peel_leading_slash(std::string* path);
peelLeadingSlash(std::string* path);
static bool
peel_trailing_slashstar(std::string* path);
peelTrailingSlashstar(std::string* path);
static std::string
peel_name(std::string* path);
peelName(std::string* path);
//--------------------------------------------------------------------------

View File

@@ -27,7 +27,7 @@ struct Zero
};
namespace {
constexpr Zero zero{};
constexpr Zero kZERO{};
} // namespace
/** Default implementation of signum calls the method on the class. */
@@ -102,42 +102,42 @@ template <typename T>
bool
operator==(Zero, T const& t)
{
return t == zero;
return t == kZERO;
}
template <typename T>
bool
operator!=(Zero, T const& t)
{
return t != zero;
return t != kZERO;
}
template <typename T>
bool
operator<(Zero, T const& t)
{
return t > zero;
return t > kZERO;
}
template <typename T>
bool
operator>(Zero, T const& t)
{
return t < zero;
return t < kZERO;
}
template <typename T>
bool
operator>=(Zero, T const& t)
{
return t <= zero;
return t <= kZERO;
}
template <typename T>
bool
operator<=(Zero, T const& t)
{
return t >= zero;
return t >= kZERO;
}
} // namespace beast

View File

@@ -9,16 +9,16 @@ namespace beast {
namespace detail {
template <class = void>
class xor_shift_engine
class XorShiftEngine
{
public:
using result_type = std::uint64_t;
xor_shift_engine(xor_shift_engine const&) = default;
xor_shift_engine&
operator=(xor_shift_engine const&) = default;
XorShiftEngine(XorShiftEngine const&) = default;
XorShiftEngine&
operator=(XorShiftEngine const&) = default;
explicit xor_shift_engine(result_type val = 1977u);
explicit XorShiftEngine(result_type val = 1977u);
void
seed(result_type seed);
@@ -44,14 +44,14 @@ private:
};
template <class Unused>
xor_shift_engine<Unused>::xor_shift_engine(result_type val)
XorShiftEngine<Unused>::XorShiftEngine(result_type val)
{
seed(val);
}
template <class Unused>
void
xor_shift_engine<Unused>::seed(result_type seed)
XorShiftEngine<Unused>::seed(result_type seed)
{
if (seed == 0)
throw std::domain_error("invalid seed");
@@ -61,7 +61,7 @@ xor_shift_engine<Unused>::seed(result_type seed)
template <class Unused>
auto
xor_shift_engine<Unused>::operator()() -> result_type
XorShiftEngine<Unused>::operator()() -> result_type
{
result_type s1 = s_[0];
result_type const s0 = s_[1];
@@ -72,7 +72,7 @@ xor_shift_engine<Unused>::operator()() -> result_type
template <class Unused>
auto
xor_shift_engine<Unused>::murmurhash3(result_type x) -> result_type
XorShiftEngine<Unused>::murmurhash3(result_type x) -> result_type
{
x ^= x >> 33;
x *= 0xff51afd7ed558ccdULL;
@@ -91,6 +91,6 @@ xor_shift_engine<Unused>::murmurhash3(result_type x) -> result_type
http://xorshift.di.unimi.it/xorshift128plus.c
does not accept seed==0
*/
using xor_shift_engine = detail::xor_shift_engine<>;
using xor_shift_engine = detail::XorShiftEngine<>;
} // namespace beast

View File

@@ -30,7 +30,7 @@ namespace xrpl {
* \tparam Ret_t The return type of the closure.
* \tparam Args_t The argument types of the closure.
*/
template <typename Ret_t, typename... Args_t>
template <typename RetT, typename... ArgsT>
class ClosureCounter
{
private:
@@ -75,7 +75,7 @@ private:
std::remove_reference_t<Closure> closure_{};
static_assert(
std::is_same_v<decltype(closure_(std::declval<Args_t>()...)), Ret_t>,
std::is_same_v<decltype(closure_(std::declval<ArgsT>()...)), RetT>,
"Closure arguments don't match ClosureCounter Ret_t or Args_t");
public:
@@ -113,10 +113,10 @@ private:
// Note that Args_t is not deduced, it is explicit. So Args_t&&
// would be an rvalue reference, not a forwarding reference. We
// want to forward exactly what the user declared.
Ret_t
operator()(Args_t... args)
RetT
operator()(ArgsT... args)
{
return closure_(std::forward<Args_t>(args)...);
return closure_(std::forward<ArgsT>(args)...);
}
};

View File

@@ -4,18 +4,17 @@ namespace xrpl {
/// Coroutine stack size (1.5 MB). Increased from 1 MB because
/// ASAN-instrumented deep call stacks exceeded the original limit.
constexpr std::size_t coroStackSize = 1536 * 1024;
constexpr std::size_t kCORO_STACK_SIZE = 1536 * 1024;
template <class F>
JobQueue::Coro::Coro(Coro_create_t, JobQueue& jq, JobType type, std::string const& name, F&& f)
JobQueue::Coro::Coro(CoroCreateT, JobQueue& jq, JobType type, std::string const& name, F&& f)
: jq_(jq)
, type_(type)
, name_(name)
, coro_(
boost::context::protected_fixedsize_stack(coroStackSize),
[this,
fn = std::forward<F>(f)](boost::coroutines2::coroutine<void>::push_type& do_yield) {
yield_ = &do_yield;
boost::context::protected_fixedsize_stack(kCORO_STACK_SIZE),
[this, fn = std::forward<F>(f)](boost::coroutines2::coroutine<void>::push_type& doYield) {
yield_ = &doYield;
yield();
fn(shared_from_this());
#ifndef NDEBUG
@@ -36,7 +35,7 @@ inline void
JobQueue::Coro::yield() const
{
{
std::scoped_lock lock(jq_.m_mutex);
std::scoped_lock lock(jq_.m_mutex_);
++jq_.nSuspend_;
}
(*yield_)();
@@ -71,7 +70,7 @@ JobQueue::Coro::resume()
running_ = true;
}
{
std::scoped_lock lk(jq_.m_mutex);
std::scoped_lock lk(jq_.m_mutex_);
--jq_.nSuspend_;
}
auto saved = detail::getLocalValues().release();
@@ -115,7 +114,7 @@ JobQueue::Coro::expectEarlyExit()
//
// That said, since we're outside the Coro's stack, we need to
// decrement the nSuspend that the Coro's call to yield caused.
std::scoped_lock lock(jq_.m_mutex);
std::scoped_lock lock(jq_.m_mutex_);
--jq_.nSuspend_;
#ifndef NDEBUG
finished_ = true;

View File

@@ -212,7 +212,7 @@ public:
uint256 const& key,
PeerShortID peer,
HashRouterFlags& flags,
std::chrono::seconds tx_interval);
std::chrono::seconds txInterval);
/** Set the flags on a hash.
@@ -250,7 +250,7 @@ private:
Setup const setup_;
// Stores all suppressed hashes and their expiration time
beast::aged_unordered_map<uint256, Entry, Stopwatch::clock_type, hardened_hash<strong_hash>>
beast::aged_unordered_map<uint256, Entry, Stopwatch::clock_type, HardenedHash<strong_hash>>
suppressionMap_;
};

View File

@@ -15,62 +15,62 @@ namespace xrpl {
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
enum JobType {
// Special type indicating an invalid job - will go away soon.
jtINVALID = -1,
JtInvalid = -1,
// Job types - the position in this enum indicates the job priority with
// earlier jobs having lower priority than later jobs. If you wish to
// insert a job at a specific priority, simply add it at the right location.
jtPACK, // Make a fetch pack for a peer
jtPUBOLDLEDGER, // An old ledger has been accepted
jtCLIENT, // A placeholder for the priority of all jtCLIENT jobs
jtCLIENT_SUBSCRIBE, // A websocket subscription by a client
jtCLIENT_FEE_CHANGE, // Subscription for fee change by a client
jtCLIENT_CONSENSUS, // Subscription for consensus state change by a client
jtCLIENT_ACCT_HIST, // Subscription for account history by a client
jtCLIENT_RPC, // Client RPC request
jtCLIENT_WEBSOCKET, // Client websocket request
jtRPC, // A websocket command from the client
jtSWEEP, // Sweep for stale structures
jtVALIDATION_ut, // A validation from an untrusted source
jtMANIFEST, // A validator's manifest
jtUPDATE_PF, // Update pathfinding requests
jtTRANSACTION_l, // A local transaction
jtREPLAY_REQ, // Peer request a ledger delta or a skip list
jtLEDGER_REQ, // Peer request ledger/txnset data
jtPROPOSAL_ut, // A proposal from an untrusted source
jtREPLAY_TASK, // A Ledger replay task/subtask
jtTRANSACTION, // A transaction received from the network
jtMISSING_TXN, // Request missing transactions
jtREQUESTED_TXN, // Reply with requested transactions
jtBATCH, // Apply batched transactions
jtLEDGER_DATA, // Received data for a ledger we're acquiring
jtADVANCE, // Advance validated/acquired ledgers
jtPUBLEDGER, // Publish a fully-accepted ledger
jtTXN_DATA, // Fetch a proposed set
jtWAL, // Write-ahead logging
jtVALIDATION_t, // A validation from a trusted source
jtWRITE, // Write out hashed objects
jtACCEPT, // Accept a consensus ledger
jtPROPOSAL_t, // A proposal from a trusted source
jtNETOP_CLUSTER, // NetworkOPs cluster peer report
jtNETOP_TIMER, // NetworkOPs net timer processing
jtADMIN, // An administrative operation
JtPack, // Make a fetch pack for a peer
JtPuboldledger, // An old ledger has been accepted
JtClient, // A placeholder for the priority of all jtCLIENT jobs
JtClientSubscribe, // A websocket subscription by a client
JtClientFeeChange, // Subscription for fee change by a client
JtClientConsensus, // Subscription for consensus state change by a client
JtClientAcctHist, // Subscription for account history by a client
JtClientRpc, // Client RPC request
JtClientWebsocket, // Client websocket request
JtRpc, // A websocket command from the client
JtSweep, // Sweep for stale structures
JtValidationUt, // A validation from an untrusted source
JtManifest, // A validator's manifest
JtUpdatePf, // Update pathfinding requests
JtTransactionL, // A local transaction
JtReplayReq, // Peer request a ledger delta or a skip list
JtLedgerReq, // Peer request ledger/txnset data
JtProposalUt, // A proposal from an untrusted source
JtReplayTask, // A Ledger replay task/subtask
JtTransaction, // A transaction received from the network
JtMissingTxn, // Request missing transactions
JtRequestedTxn, // Reply with requested transactions
JtBatch, // Apply batched transactions
JtLedgerData, // Received data for a ledger we're acquiring
JtAdvance, // Advance validated/acquired ledgers
JtPubledger, // Publish a fully-accepted ledger
JtTxnData, // Fetch a proposed set
JtWal, // Write-ahead logging
JtValidationT, // A validation from a trusted source
JtWrite, // Write out hashed objects
JtAccept, // Accept a consensus ledger
JtProposalT, // A proposal from a trusted source
JtNetopCluster, // NetworkOPs cluster peer report
JtNetopTimer, // NetworkOPs net timer processing
JtAdmin, // An administrative operation
// Special job types which are not dispatched by the job pool
jtPEER,
jtDISK,
jtTXN_PROC,
jtOB_SETUP,
jtPATH_FIND,
jtHO_READ,
jtHO_WRITE,
jtGENERIC, // Used just to measure time
JtPeer,
JtDisk,
JtTxnProc,
JtObSetup,
JtPathFind,
JtHoRead,
JtHoWrite,
JtGeneric, // Used just to measure time
// Node store monitoring
jtNS_SYNC_READ,
jtNS_ASYNC_READ,
jtNS_WRITE,
JtNsSyncRead,
JtNsAsyncRead,
JtNsWrite,
};
class Job : public CountedObject<Job>
@@ -105,7 +105,7 @@ public:
/** Returns the time when the job was queued. */
[[nodiscard]] clock_type::time_point const&
queue_time() const;
queueTime() const;
void
doJob();
@@ -122,12 +122,12 @@ public:
operator>=(Job const& j) const;
private:
JobType mType;
std::uint64_t mJobIndex;
std::function<void()> mJob;
std::shared_ptr<LoadEvent> m_loadEvent;
std::string mName;
clock_type::time_point m_queue_time;
JobType mType_;
std::uint64_t mJobIndex_;
std::function<void()> mJob_;
std::shared_ptr<LoadEvent> m_loadEvent_;
std::string mName_;
clock_type::time_point m_queue_time_;
};
using JobCounter = ClosureCounter<void>;

View File

@@ -24,9 +24,9 @@ class PerfLog;
} // namespace perf
class Logs;
struct Coro_create_t
struct CoroCreateT
{
explicit Coro_create_t() = default;
explicit CoroCreateT() = default;
};
/** A pool of threads to perform work.
@@ -63,7 +63,7 @@ public:
public:
// Private: Used in the implementation
template <class F>
Coro(Coro_create_t, JobQueue&, JobType, std::string const&, F&&);
Coro(CoroCreateT, JobQueue&, JobType, std::string const&, F&&);
// Not copy-constructible or assignable
Coro(Coro const&) = delete;
@@ -226,29 +226,29 @@ private:
using JobDataMap = std::map<JobType, JobTypeData>;
beast::Journal m_journal;
mutable std::mutex m_mutex;
std::uint64_t m_lastJob{0};
std::set<Job> m_jobSet;
beast::Journal m_journal_;
mutable std::mutex m_mutex_;
std::uint64_t m_lastJob_{0};
std::set<Job> m_jobSet_;
JobCounter jobCounter_;
std::atomic_bool stopping_{false};
std::atomic_bool stopped_{false};
JobDataMap m_jobData;
JobTypeData m_invalidJobData;
JobDataMap m_jobData_;
JobTypeData m_invalidJobData_;
// The number of jobs currently in processTask()
int m_processCount{0};
int m_processCount_{0};
// The number of suspended coroutines
int nSuspend_ = 0;
Workers m_workers;
Workers m_workers_;
// Statistics tracking
perf::PerfLog& perfLog_;
beast::insight::Collector::ptr m_collector;
beast::insight::Gauge job_count;
beast::insight::Hook hook;
beast::insight::Collector::ptr m_collector_;
beast::insight::Gauge job_count_;
beast::insight::Hook hook_;
std::condition_variable cv_;
@@ -397,7 +397,7 @@ JobQueue::postCoro(JobType t, std::string const& name, F&& f)
Last param is the function the coroutine runs. Signature of
void(std::shared_ptr<Coro>).
*/
auto coro = std::make_shared<Coro>(Coro_create_t{}, *this, t, name, std::forward<F>(f));
auto coro = std::make_shared<Coro>(CoroCreateT{}, *this, t, name, std::forward<F>(f));
if (!coro->post())
{
// The Coro was not successfully posted. Disable it so it's destructor

View File

@@ -11,10 +11,10 @@ namespace xrpl {
struct JobTypeData
{
private:
LoadMonitor m_load;
LoadMonitor m_load_;
/* Support for insight */
beast::insight::Collector::ptr m_collector;
beast::insight::Collector::ptr m_collector_;
public:
/* The job category which we represent */
@@ -34,18 +34,18 @@ public:
beast::insight::Event execute;
JobTypeData(
JobTypeInfo const& info_,
JobTypeInfo const& info,
beast::insight::Collector::ptr collector,
Logs& logs) noexcept
: m_load(logs.journal("LoadMonitor")), m_collector(std::move(collector)), info(info_)
: m_load_(logs.journal("LoadMonitor")), m_collector_(std::move(collector)), info(info)
{
m_load.setTargetLatency(info.getAverageLatency(), info.getPeakLatency());
m_load_.setTargetLatency(info.getAverageLatency(), info.getPeakLatency());
if (!info.special())
{
dequeue = m_collector->make_event(info.name() + "_q");
execute = m_collector->make_event(info.name());
dequeue = m_collector_->makeEvent(info.name() + "_q");
execute = m_collector_->makeEvent(info.name());
}
}
@@ -69,13 +69,13 @@ public:
LoadMonitor&
load()
{
return m_load;
return m_load_;
}
LoadMonitor::Stats
stats()
{
return m_load.getStats();
return m_load_.getStats();
}
};

View File

@@ -8,19 +8,19 @@ namespace xrpl {
class JobTypeInfo
{
private:
JobType const m_type;
std::string const m_name;
JobType const m_type_;
std::string const m_name_;
/** The limit on the number of running jobs for this job type.
A limit of 0 marks this as a "special job" which is not
dispatched via the job queue.
*/
int const m_limit;
int const m_limit_;
/** Average and peak latencies for this job type. 0 is none specified */
std::chrono::milliseconds const m_avgLatency;
std::chrono::milliseconds const m_peakLatency;
std::chrono::milliseconds const m_avgLatency_;
std::chrono::milliseconds const m_peakLatency_;
public:
// Not default constructible
@@ -32,48 +32,48 @@ public:
int limit,
std::chrono::milliseconds avgLatency,
std::chrono::milliseconds peakLatency)
: m_type(type)
, m_name(std::move(name))
, m_limit(limit)
, m_avgLatency(avgLatency)
, m_peakLatency(peakLatency)
: m_type_(type)
, m_name_(std::move(name))
, m_limit_(limit)
, m_avgLatency_(avgLatency)
, m_peakLatency_(peakLatency)
{
}
[[nodiscard]] JobType
type() const
{
return m_type;
return m_type_;
}
[[nodiscard]] std::string const&
name() const
{
return m_name;
return m_name_;
}
[[nodiscard]] int
limit() const
{
return m_limit;
return m_limit_;
}
[[nodiscard]] bool
special() const
{
return m_limit == 0;
return m_limit_ == 0;
}
[[nodiscard]] std::chrono::milliseconds
getAverageLatency() const
{
return m_avgLatency;
return m_avgLatency_;
}
[[nodiscard]] std::chrono::milliseconds
getPeakLatency() const
{
return m_peakLatency;
return m_peakLatency_;
}
};

View File

@@ -17,7 +17,7 @@ public:
private:
JobTypes()
: m_unknown(
jtINVALID,
JtInvalid,
"invalid",
0,
std::chrono::milliseconds{0},
@@ -49,53 +49,53 @@ private:
// clang-format off
// avg peak
// JobType name limit latency latency
add(jtPACK, "makeFetchPack", 1, 0ms, 0ms);
add(jtPUBOLDLEDGER, "publishAcqLedger", 2, 10000ms, 15000ms);
add(jtVALIDATION_ut, "untrustedValidation", maxLimit, 2000ms, 5000ms);
add(jtMANIFEST, "manifest", maxLimit, 2000ms, 5000ms);
add(jtTRANSACTION_l, "localTransaction", maxLimit, 100ms, 500ms);
add(jtREPLAY_REQ, "ledgerReplayRequest", 10, 250ms, 1000ms);
add(jtLEDGER_REQ, "ledgerRequest", 3, 0ms, 0ms);
add(jtPROPOSAL_ut, "untrustedProposal", maxLimit, 500ms, 1250ms);
add(jtREPLAY_TASK, "ledgerReplayTask", maxLimit, 0ms, 0ms);
add(jtLEDGER_DATA, "ledgerData", 3, 0ms, 0ms);
add(jtCLIENT, "clientCommand", maxLimit, 2000ms, 5000ms);
add(jtCLIENT_SUBSCRIBE, "clientSubscribe", maxLimit, 2000ms, 5000ms);
add(jtCLIENT_FEE_CHANGE, "clientFeeChange", maxLimit, 2000ms, 5000ms);
add(jtCLIENT_CONSENSUS, "clientConsensus", maxLimit, 2000ms, 5000ms);
add(jtCLIENT_ACCT_HIST, "clientAccountHistory", maxLimit, 2000ms, 5000ms);
add(jtCLIENT_RPC, "clientRPC", maxLimit, 2000ms, 5000ms);
add(jtCLIENT_WEBSOCKET, "clientWebsocket", maxLimit, 2000ms, 5000ms);
add(jtRPC, "RPC", maxLimit, 0ms, 0ms);
add(jtUPDATE_PF, "updatePaths", 1, 0ms, 0ms);
add(jtTRANSACTION, "transaction", maxLimit, 250ms, 1000ms);
add(jtBATCH, "batch", maxLimit, 250ms, 1000ms);
add(jtADVANCE, "advanceLedger", maxLimit, 0ms, 0ms);
add(jtPUBLEDGER, "publishNewLedger", maxLimit, 3000ms, 4500ms);
add(jtTXN_DATA, "fetchTxnData", 5, 0ms, 0ms);
add(jtWAL, "writeAhead", maxLimit, 1000ms, 2500ms);
add(jtVALIDATION_t, "trustedValidation", maxLimit, 500ms, 1500ms);
add(jtWRITE, "writeObjects", maxLimit, 1750ms, 2500ms);
add(jtACCEPT, "acceptLedger", maxLimit, 0ms, 0ms);
add(jtPROPOSAL_t, "trustedProposal", maxLimit, 100ms, 500ms);
add(jtSWEEP, "sweep", 1, 0ms, 0ms);
add(jtNETOP_CLUSTER, "clusterReport", 1, 9999ms, 9999ms);
add(jtNETOP_TIMER, "heartbeat", 1, 999ms, 999ms);
add(jtADMIN, "administration", maxLimit, 0ms, 0ms);
add(jtMISSING_TXN, "handleHaveTransactions", 1200, 0ms, 0ms);
add(jtREQUESTED_TXN, "doTransactions", 1200, 0ms, 0ms);
add(JtPack, "makeFetchPack", 1, 0ms, 0ms);
add(JtPuboldledger, "publishAcqLedger", 2, 10000ms, 15000ms);
add(JtValidationUt, "untrustedValidation", maxLimit, 2000ms, 5000ms);
add(JtManifest, "manifest", maxLimit, 2000ms, 5000ms);
add(JtTransactionL, "localTransaction", maxLimit, 100ms, 500ms);
add(JtReplayReq, "ledgerReplayRequest", 10, 250ms, 1000ms);
add(JtLedgerReq, "ledgerRequest", 3, 0ms, 0ms);
add(JtProposalUt, "untrustedProposal", maxLimit, 500ms, 1250ms);
add(JtReplayTask, "ledgerReplayTask", maxLimit, 0ms, 0ms);
add(JtLedgerData, "ledgerData", 3, 0ms, 0ms);
add(JtClient, "clientCommand", maxLimit, 2000ms, 5000ms);
add(JtClientSubscribe, "clientSubscribe", maxLimit, 2000ms, 5000ms);
add(JtClientFeeChange, "clientFeeChange", maxLimit, 2000ms, 5000ms);
add(JtClientConsensus, "clientConsensus", maxLimit, 2000ms, 5000ms);
add(JtClientAcctHist, "clientAccountHistory", maxLimit, 2000ms, 5000ms);
add(JtClientRpc, "clientRPC", maxLimit, 2000ms, 5000ms);
add(JtClientWebsocket, "clientWebsocket", maxLimit, 2000ms, 5000ms);
add(JtRpc, "RPC", maxLimit, 0ms, 0ms);
add(JtUpdatePf, "updatePaths", 1, 0ms, 0ms);
add(JtTransaction, "transaction", maxLimit, 250ms, 1000ms);
add(JtBatch, "batch", maxLimit, 250ms, 1000ms);
add(JtAdvance, "advanceLedger", maxLimit, 0ms, 0ms);
add(JtPubledger, "publishNewLedger", maxLimit, 3000ms, 4500ms);
add(JtTxnData, "fetchTxnData", 5, 0ms, 0ms);
add(JtWal, "writeAhead", maxLimit, 1000ms, 2500ms);
add(JtValidationT, "trustedValidation", maxLimit, 500ms, 1500ms);
add(JtWrite, "writeObjects", maxLimit, 1750ms, 2500ms);
add(JtAccept, "acceptLedger", maxLimit, 0ms, 0ms);
add(JtProposalT, "trustedProposal", maxLimit, 100ms, 500ms);
add(JtSweep, "sweep", 1, 0ms, 0ms);
add(JtNetopCluster, "clusterReport", 1, 9999ms, 9999ms);
add(JtNetopTimer, "heartbeat", 1, 999ms, 999ms);
add(JtAdmin, "administration", maxLimit, 0ms, 0ms);
add(JtMissingTxn, "handleHaveTransactions", 1200, 0ms, 0ms);
add(JtRequestedTxn, "doTransactions", 1200, 0ms, 0ms);
add(jtPEER, "peerCommand", 0, 200ms, 2500ms);
add(jtDISK, "diskAccess", 0, 500ms, 1000ms);
add(jtTXN_PROC, "processTransaction", 0, 0ms, 0ms);
add(jtOB_SETUP, "orderBookSetup", 0, 0ms, 0ms);
add(jtPATH_FIND, "pathFind", 0, 0ms, 0ms);
add(jtHO_READ, "nodeRead", 0, 0ms, 0ms);
add(jtHO_WRITE, "nodeWrite", 0, 0ms, 0ms);
add(jtGENERIC, "generic", 0, 0ms, 0ms);
add(jtNS_SYNC_READ, "SyncReadNode", 0, 0ms, 0ms);
add(jtNS_ASYNC_READ, "AsyncReadNode", 0, 0ms, 0ms);
add(jtNS_WRITE, "WriteNode", 0, 0ms, 0ms);
add(JtPeer, "peerCommand", 0, 200ms, 2500ms);
add(JtDisk, "diskAccess", 0, 500ms, 1000ms);
add(JtTxnProc, "processTransaction", 0, 0ms, 0ms);
add(JtObSetup, "orderBookSetup", 0, 0ms, 0ms);
add(JtPathFind, "pathFind", 0, 0ms, 0ms);
add(JtHoRead, "nodeRead", 0, 0ms, 0ms);
add(JtHoWrite, "nodeWrite", 0, 0ms, 0ms);
add(JtGeneric, "generic", 0, 0ms, 0ms);
add(JtNsSyncRead, "SyncReadNode", 0, 0ms, 0ms);
add(JtNsAsyncRead, "AsyncReadNode", 0, 0ms, 0ms);
add(JtNsWrite, "WriteNode", 0, 0ms, 0ms);
// clang-format on
}
@@ -103,8 +103,8 @@ public:
static JobTypes const&
instance()
{
static JobTypes const types;
return types;
static JobTypes const kTYPES;
return kTYPES;
}
static std::string const&

View File

@@ -54,13 +54,13 @@ private:
std::mutex mutex_;
std::uint64_t mCounts{0};
int mLatencyEvents{0};
std::chrono::milliseconds mLatencyMSAvg;
std::chrono::milliseconds mLatencyMSPeak;
std::chrono::milliseconds mTargetLatencyAvg;
std::chrono::milliseconds mTargetLatencyPk;
UptimeClock::time_point mLastUpdate;
std::uint64_t mCounts_{0};
int mLatencyEvents_{0};
std::chrono::milliseconds mLatencyMSAvg_;
std::chrono::milliseconds mLatencyMSPeak_;
std::chrono::milliseconds mTargetLatencyAvg_;
std::chrono::milliseconds mTargetLatencyPk_;
UptimeClock::time_point mLastUpdate_;
beast::Journal const j_;
};

View File

@@ -81,7 +81,7 @@ public:
* @throw soci::soci_error
*/
std::optional<PeerReservation>
insert_or_assign(PeerReservation const& reservation);
insertOrAssign(PeerReservation const& reservation);
/**
* @return the erased reservation if it existed
@@ -93,7 +93,7 @@ private:
beast::Journal mutable journal_;
std::mutex mutable mutex_;
DatabaseCon* connection_{};
std::unordered_set<PeerReservation, beast::uhash<>, KeyEqual> table_;
std::unordered_set<PeerReservation, beast::Uhash<>, KeyEqual> table_;
};
} // namespace xrpl

View File

@@ -165,12 +165,12 @@ measureDurationAndLog(
std::chrono::duration<Rep, Period> maxDelay,
beast::Journal const& journal)
{
auto start_time = std::chrono::high_resolution_clock::now();
auto startTime = std::chrono::high_resolution_clock::now();
auto result = func();
auto end_time = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time);
auto endTime = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);
if (duration > maxDelay)
{
JLOG(journal.warn()) << actionDescription << " took " << duration.count() << " ms";

View File

@@ -176,7 +176,7 @@ private:
run();
private:
Workers& m_workers;
Workers& m_workers_;
std::string const threadName_;
int const instance_;
@@ -192,19 +192,19 @@ private:
deleteWorkers(beast::LockFreeStack<Worker>& stack);
private:
Callback& m_callback;
Callback& m_callback_;
perf::PerfLog* perfLog_;
std::string m_threadNames; // The name to give each thread
std::condition_variable m_cv; // signaled when all threads paused
std::mutex m_mut;
bool m_allPaused{true};
semaphore m_semaphore; // each pending task is 1 resource
int m_numberOfThreads{0}; // how many we want active now
std::atomic<int> m_activeCount; // to know when all are paused
std::atomic<int> m_pauseCount; // how many threads need to pause now
std::atomic<int> m_runningTaskCount; // how many calls to processTask() active
beast::LockFreeStack<Worker> m_everyone; // holds all created workers
beast::LockFreeStack<Worker, PausedTag> m_paused; // holds just paused workers
std::string m_threadNames_; // The name to give each thread
std::condition_variable m_cv_; // signaled when all threads paused
std::mutex m_mut_;
bool m_allPaused_{true};
semaphore m_semaphore_; // each pending task is 1 resource
int m_numberOfThreads_{0}; // how many we want active now
std::atomic<int> m_activeCount_; // to know when all are paused
std::atomic<int> m_pauseCount_; // how many threads need to pause now
std::atomic<int> m_runningTaskCount_; // how many calls to processTask() active
beast::LockFreeStack<Worker> m_everyone_; // holds all created workers
beast::LockFreeStack<Worker, PausedTag> m_paused_; // holds just paused workers
};
} // namespace xrpl

View File

@@ -34,12 +34,12 @@
namespace xrpl {
template <class Mutex, class CondVar>
class basic_semaphore
class BasicSemaphore
{
private:
Mutex m_mutex;
CondVar m_cond;
std::size_t m_count;
Mutex m_mutex_;
CondVar m_cond_;
std::size_t m_count_;
public:
using size_type = std::size_t;
@@ -47,7 +47,7 @@ public:
/** Create the semaphore, with an optional initial count.
If unspecified, the initial count is zero.
*/
explicit basic_semaphore(size_type count = 0) : m_count(count)
explicit BasicSemaphore(size_type count = 0) : m_count_(count)
{
}
@@ -55,35 +55,35 @@ public:
void
notify()
{
std::scoped_lock const lock{m_mutex};
++m_count;
m_cond.notify_one();
std::scoped_lock const lock{m_mutex_};
++m_count_;
m_cond_.notify_one();
}
/** Block until notify is called. */
void
wait()
{
std::unique_lock lock{m_mutex};
while (m_count == 0)
m_cond.wait(lock);
--m_count;
std::unique_lock lock{m_mutex_};
while (m_count_ == 0)
m_cond_.wait(lock);
--m_count_;
}
/** Perform a non-blocking wait.
@return `true` If the wait would be satisfied.
*/
bool
try_wait()
tryWait()
{
std::scoped_lock lock{m_mutex};
if (m_count == 0)
std::scoped_lock lock{m_mutex_};
if (m_count_ == 0)
return false;
--m_count;
--m_count_;
return true;
}
};
using semaphore = basic_semaphore<std::mutex, std::condition_variable>;
using semaphore = BasicSemaphore<std::mutex, std::condition_variable>;
} // namespace xrpl

View File

@@ -18,14 +18,14 @@ namespace Json {
// Used throughout JSON layer
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
enum ValueType {
nullValue = 0, ///< 'null' value
intValue, ///< signed integer value
uintValue, ///< unsigned integer value
realValue, ///< double value
stringValue, ///< UTF-8 string value
booleanValue, ///< bool value
arrayValue, ///< array value (ordered list)
objectValue ///< object value (collection of name/value pairs).
NullValue = 0, ///< 'null' value
IntValue, ///< signed integer value
UintValue, ///< unsigned integer value
RealValue, ///< double value
StringValue, ///< UTF-8 string value
BooleanValue, ///< bool value
ArrayValue, ///< array value (ordered list)
ObjectValue ///< object value (collection of name/value pairs).
};
/** \brief Lightweight wrapper to tag static string.
@@ -56,7 +56,7 @@ public:
}
[[nodiscard]] constexpr char const*
c_str() const
cStr() const
{
return str_;
}
@@ -68,7 +68,7 @@ private:
inline bool
operator==(StaticString x, StaticString y)
{
return strcmp(x.c_str(), y.c_str()) == 0;
return strcmp(x.cStr(), y.cStr()) == 0;
}
inline bool
@@ -80,7 +80,7 @@ operator!=(StaticString x, StaticString y)
inline bool
operator==(std::string const& x, StaticString y)
{
return strcmp(x.c_str(), y.c_str()) == 0;
return strcmp(x.c_str(), y.cStr()) == 0;
}
inline bool
@@ -140,10 +140,10 @@ public:
using Int = Json::Int;
using ArrayIndex = UInt;
static Value const null;
static constexpr Int minInt = std::numeric_limits<Int>::min();
static constexpr Int maxInt = std::numeric_limits<Int>::max();
static constexpr UInt maxUInt = std::numeric_limits<UInt>::max();
static Value const kNULL;
static constexpr Int kMIN_INT = std::numeric_limits<Int>::min();
static constexpr Int kMAX_INT = std::numeric_limits<Int>::max();
static constexpr UInt kMAX_U_INT = std::numeric_limits<UInt>::max();
private:
class CZString
@@ -151,7 +151,7 @@ private:
public:
// Stored as int field, implicit conversion
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
enum DuplicationPolicy { noDuplication = 0, duplicate, duplicateOnCopy };
enum DuplicationPolicy { NoDuplication = 0, Duplicate, DuplicateOnCopy };
CZString(int index);
CZString(char const* cstr, DuplicationPolicy allocate);
CZString(CZString const& other);
@@ -165,7 +165,7 @@ private:
[[nodiscard]] int
index() const;
[[nodiscard]] char const*
c_str() const;
cStr() const;
[[nodiscard]] bool
isStaticString() const;
@@ -193,7 +193,7 @@ public:
Json::Value obj_value(Json::objectValue); // {}
\endcode
*/
Value(ValueType type = nullValue);
Value(ValueType type = NullValue);
Value(Int value);
Value(UInt value);
Value(double value);
@@ -418,11 +418,11 @@ private:
union ValueHolder
{
Int int_;
UInt uint_;
double real_;
UInt uint;
double real;
bool bool_;
char* string_;
ObjectValues* map_{nullptr};
char* string;
ObjectValues* map{nullptr};
} value_;
ValueType type_ : 8;
int allocated_ : 1 {}; // Notes: if declared as bool, bitfield is useless.
@@ -477,7 +477,7 @@ class ValueAllocator
public:
// Need to be named before converting
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
enum { unknown = (unsigned)-1 };
enum { Unknown = (unsigned)-1 };
virtual ~ValueAllocator() = default;
@@ -486,7 +486,7 @@ public:
virtual void
releaseMemberName(char* memberName) = 0;
virtual char*
duplicateStringValue(char const* value, unsigned int length = unknown) = 0;
duplicateStringValue(char const* value, unsigned int length = Unknown) = 0;
virtual void
releaseStringValue(char* value) = 0;
};

View File

@@ -204,31 +204,31 @@ write_value(Write const& write, Value const& value)
{
switch (value.type())
{
case nullValue:
case NullValue:
write("null", 4);
break;
case intValue:
case IntValue:
write_string(write, valueToString(value.asInt()));
break;
case uintValue:
case UintValue:
write_string(write, valueToString(value.asUInt()));
break;
case realValue:
case RealValue:
write_string(write, valueToString(value.asDouble()));
break;
case stringValue:
case StringValue:
write_string(write, valueToQuotedString(value.asCString()));
break;
case booleanValue:
case BooleanValue:
write_string(write, valueToString(value.asBool()));
break;
case arrayValue: {
case ArrayValue: {
write("[", 1);
int const size = value.size();
for (int index = 0; index < size; ++index)
@@ -241,7 +241,7 @@ write_value(Write const& write, Value const& value)
break;
}
case objectValue: {
case ObjectValue: {
Value::Members const members = value.getMemberNames();
write("{", 1);
for (auto it = members.begin(); it != members.end(); ++it)

View File

@@ -10,56 +10,56 @@ namespace xrpl {
// Bitwise flag enum with existing operator overloads
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
enum ApplyFlags : std::uint32_t {
tapNONE = 0x00,
TapNone = 0x00,
// This is a local transaction with the
// fail_hard flag set.
tapFAIL_HARD = 0x10,
TapFailHard = 0x10,
// This is not the transaction's last pass
// Transaction can be retried, soft failures allowed
tapRETRY = 0x20,
TapRetry = 0x20,
// Transaction came from a privileged source
tapUNLIMITED = 0x400,
TapUnlimited = 0x400,
// Transaction is executing as part of a batch
tapBATCH = 0x800,
TapBatch = 0x800,
// Transaction shouldn't be applied
// Signatures shouldn't be checked
tapDRY_RUN = 0x1000
TapDryRun = 0x1000
};
constexpr ApplyFlags
operator|(ApplyFlags const& lhs, ApplyFlags const& rhs)
{
return safe_cast<ApplyFlags>(
safe_cast<std::underlying_type_t<ApplyFlags>>(lhs) |
safe_cast<std::underlying_type_t<ApplyFlags>>(rhs));
return safeCast<ApplyFlags>(
safeCast<std::underlying_type_t<ApplyFlags>>(lhs) |
safeCast<std::underlying_type_t<ApplyFlags>>(rhs));
}
static_assert((tapFAIL_HARD | tapRETRY) == safe_cast<ApplyFlags>(0x30u), "ApplyFlags operator |");
static_assert((tapRETRY | tapFAIL_HARD) == safe_cast<ApplyFlags>(0x30u), "ApplyFlags operator |");
static_assert((TapFailHard | TapRetry) == safeCast<ApplyFlags>(0x30u), "ApplyFlags operator |");
static_assert((TapRetry | TapFailHard) == safeCast<ApplyFlags>(0x30u), "ApplyFlags operator |");
constexpr ApplyFlags
operator&(ApplyFlags const& lhs, ApplyFlags const& rhs)
{
return safe_cast<ApplyFlags>(
safe_cast<std::underlying_type_t<ApplyFlags>>(lhs) &
safe_cast<std::underlying_type_t<ApplyFlags>>(rhs));
return safeCast<ApplyFlags>(
safeCast<std::underlying_type_t<ApplyFlags>>(lhs) &
safeCast<std::underlying_type_t<ApplyFlags>>(rhs));
}
static_assert((tapFAIL_HARD & tapRETRY) == tapNONE, "ApplyFlags operator &");
static_assert((tapRETRY & tapFAIL_HARD) == tapNONE, "ApplyFlags operator &");
static_assert((TapFailHard & TapRetry) == TapNone, "ApplyFlags operator &");
static_assert((TapRetry & TapFailHard) == TapNone, "ApplyFlags operator &");
constexpr ApplyFlags
operator~(ApplyFlags const& flags)
{
return safe_cast<ApplyFlags>(~safe_cast<std::underlying_type_t<ApplyFlags>>(flags));
return safeCast<ApplyFlags>(~safeCast<std::underlying_type_t<ApplyFlags>>(flags));
}
static_assert(~tapRETRY == safe_cast<ApplyFlags>(0xFFFFFFDFu), "ApplyFlags operator ~");
static_assert(~TapRetry == safeCast<ApplyFlags>(0xFFFFFFDFu), "ApplyFlags operator ~");
inline ApplyFlags
operator|=(ApplyFlags& lhs, ApplyFlags const& rhs)

View File

@@ -17,7 +17,7 @@ private:
DigestAwareReadView const& base_;
CachedSLEs& cache_;
std::mutex mutable mutex_;
std::unordered_map<key_type, uint256, hardened_hash<>> mutable map_;
std::unordered_map<key_type, uint256, HardenedHash<>> mutable map_;
public:
CachedViewImpl() = delete;
@@ -69,31 +69,31 @@ public:
return base_.succ(key, last);
}
std::unique_ptr<sles_type::iter_base>
std::unique_ptr<SlesType::iter_base>
slesBegin() const override
{
return base_.slesBegin();
}
std::unique_ptr<sles_type::iter_base>
std::unique_ptr<SlesType::iter_base>
slesEnd() const override
{
return base_.slesEnd();
}
std::unique_ptr<sles_type::iter_base>
std::unique_ptr<SlesType::iter_base>
slesUpperBound(uint256 const& key) const override
{
return base_.slesUpperBound(key);
}
std::unique_ptr<txs_type::iter_base>
std::unique_ptr<TxsType::iter_base>
txsBegin() const override
{
return base_.txsBegin();
}
std::unique_ptr<txs_type::iter_base>
std::unique_ptr<TxsType::iter_base>
txsEnd() const override
{
return base_.txsEnd();

View File

@@ -20,11 +20,11 @@ class TransactionMaster;
class SqliteStatement;
struct create_genesis_t
struct CreateGenesisT
{
explicit create_genesis_t() = default;
explicit CreateGenesisT() = default;
};
extern create_genesis_t const create_genesis;
extern CreateGenesisT const kCREATE_GENESIS;
/** Holds a ledger.
@@ -81,7 +81,7 @@ public:
Amendments specified are enabled in the genesis ledger
*/
Ledger(
create_genesis_t,
CreateGenesisT,
Rules rules,
Fees const& fees,
std::vector<uint256> const& amendments,
@@ -169,19 +169,19 @@ public:
std::shared_ptr<SLE const>
read(Keylet const& k) const override;
std::unique_ptr<sles_type::iter_base>
std::unique_ptr<SlesType::iter_base>
slesBegin() const override;
std::unique_ptr<sles_type::iter_base>
std::unique_ptr<SlesType::iter_base>
slesEnd() const override;
std::unique_ptr<sles_type::iter_base>
std::unique_ptr<SlesType::iter_base>
slesUpperBound(uint256 const& key) const override;
std::unique_ptr<txs_type::iter_base>
std::unique_ptr<TxsType::iter_base>
txsBegin() const override;
std::unique_ptr<txs_type::iter_base>
std::unique_ptr<TxsType::iter_base>
txsEnd() const override;
bool
@@ -249,7 +249,7 @@ public:
bool
isImmutable() const
{
return mImmutable;
return mImmutable_;
}
/* Mark this ledger as "should be full".
@@ -392,7 +392,7 @@ private:
static std::pair<std::shared_ptr<STTx const>, std::shared_ptr<STObject const>>
deserializeTxPlusMeta(SHAMapItem const& item);
bool mImmutable;
bool mImmutable_;
// A SHAMap containing the transactions associated with this ledger.
SHAMap mutable txMap_;

View File

@@ -20,20 +20,20 @@ namespace xrpl {
rules of open ledgers applied during transaction
processing.
*/
inline constexpr struct open_ledger_t
inline constexpr struct OpenLedgerT
{
explicit constexpr open_ledger_t() = default;
} open_ledger{};
explicit constexpr OpenLedgerT() = default;
} kOPEN_LEDGER{};
/** Batch view construction tag.
Views constructed with this tag are part of a stack of views
used during batch transaction applied.
*/
inline constexpr struct batch_view_t
inline constexpr struct BatchViewT
{
explicit constexpr batch_view_t() = default;
} batch_view{};
explicit constexpr BatchViewT() = default;
} kBATCH_VIEW{};
//------------------------------------------------------------------------------
@@ -47,20 +47,20 @@ private:
// Initial size for the monotonic_buffer_resource used for allocations
// The size was chosen from the old `qalloc` code (which this replaces).
// It is unclear how the size initially chosen in qalloc.
static constexpr size_t initialBufferSize = kilobytes(256);
static constexpr size_t kINITIAL_BUFFER_SIZE = kilobytes(256);
class txs_iter_impl;
struct txData
struct TxData
{
std::shared_ptr<Serializer const> txn;
std::shared_ptr<Serializer const> meta;
// Constructor needed for emplacement in std::map
txData(
std::shared_ptr<Serializer const> const& txn_,
std::shared_ptr<Serializer const> const& meta_)
: txn(txn_), meta(meta_)
TxData(
std::shared_ptr<Serializer const> const& txn,
std::shared_ptr<Serializer const> const& meta)
: txn(txn), meta(meta)
{
}
};
@@ -70,9 +70,9 @@ private:
// functions b/c clang does not support pmr yet (as-of 9/2020)
using txs_map = std::map<
key_type,
txData,
TxData,
std::less<key_type>,
boost::container::pmr::polymorphic_allocator<std::pair<key_type const, txData>>>;
boost::container::pmr::polymorphic_allocator<std::pair<key_type const, TxData>>>;
// monotonic_resource_ must outlive `items_`. Make a pointer so it may be
// easily moved.
@@ -133,17 +133,17 @@ public:
all newly inserted tx.
*/
OpenView(
open_ledger_t,
OpenLedgerT,
ReadView const* base,
Rules rules,
std::shared_ptr<void const> hold = nullptr);
OpenView(open_ledger_t, Rules const& rules, std::shared_ptr<ReadView const> const& base)
: OpenView(open_ledger, &*base, rules, base)
OpenView(OpenLedgerT, Rules const& rules, std::shared_ptr<ReadView const> const& base)
: OpenView(kOPEN_LEDGER, &*base, rules, base)
{
}
OpenView(batch_view_t, OpenView& base) : OpenView(std::addressof(base))
OpenView(BatchViewT, OpenView& base) : OpenView(std::addressof(base))
{
baseTxCount_ = base.txCount();
}
@@ -200,19 +200,19 @@ public:
std::shared_ptr<SLE const>
read(Keylet const& k) const override;
std::unique_ptr<sles_type::iter_base>
std::unique_ptr<SlesType::iter_base>
slesBegin() const override;
std::unique_ptr<sles_type::iter_base>
std::unique_ptr<SlesType::iter_base>
slesEnd() const override;
std::unique_ptr<sles_type::iter_base>
std::unique_ptr<SlesType::iter_base>
slesUpperBound(uint256 const& key) const override;
std::unique_ptr<txs_type::iter_base>
std::unique_ptr<TxsType::iter_base>
txsBegin() const override;
std::unique_ptr<txs_type::iter_base>
std::unique_ptr<TxsType::iter_base>
txsEnd() const override;
bool

View File

@@ -36,25 +36,25 @@ public:
using mapped_type = std::shared_ptr<SLE const>;
struct sles_type : detail::ReadViewFwdRange<std::shared_ptr<SLE const>>
struct SlesType : detail::ReadViewFwdRange<std::shared_ptr<SLE const>>
{
explicit sles_type(ReadView const& view);
[[nodiscard]] iterator
explicit SlesType(ReadView const& view);
[[nodiscard]] Iterator
begin() const;
[[nodiscard]] iterator
[[nodiscard]] Iterator
end() const;
[[nodiscard]] iterator
upper_bound(key_type const& key) const;
[[nodiscard]] Iterator
upperBound(key_type const& key) const;
};
struct txs_type : detail::ReadViewFwdRange<tx_type>
struct TxsType : detail::ReadViewFwdRange<tx_type>
{
explicit txs_type(ReadView const& view);
explicit TxsType(ReadView const& view);
[[nodiscard]] bool
empty() const;
[[nodiscard]] iterator
[[nodiscard]] Iterator
begin() const;
[[nodiscard]] iterator
[[nodiscard]] Iterator
end() const;
};
@@ -189,23 +189,23 @@ public:
}
// used by the implementation
[[nodiscard]] virtual std::unique_ptr<sles_type::iter_base>
[[nodiscard]] virtual std::unique_ptr<SlesType::iter_base>
slesBegin() const = 0;
// used by the implementation
[[nodiscard]] virtual std::unique_ptr<sles_type::iter_base>
[[nodiscard]] virtual std::unique_ptr<SlesType::iter_base>
slesEnd() const = 0;
// used by the implementation
[[nodiscard]] virtual std::unique_ptr<sles_type::iter_base>
[[nodiscard]] virtual std::unique_ptr<SlesType::iter_base>
slesUpperBound(key_type const& key) const = 0;
// used by the implementation
[[nodiscard]] virtual std::unique_ptr<txs_type::iter_base>
[[nodiscard]] virtual std::unique_ptr<TxsType::iter_base>
txsBegin() const = 0;
// used by the implementation
[[nodiscard]] virtual std::unique_ptr<txs_type::iter_base>
[[nodiscard]] virtual std::unique_ptr<TxsType::iter_base>
txsEnd() const = 0;
/** Returns `true` if a tx exists in the tx map.
@@ -236,10 +236,10 @@ public:
@note Visiting each state entry in the ledger can
become quite expensive as the ledger grows.
*/
sles_type sles;
SlesType sles;
// The range of transactions
txs_type txs;
TxsType txs;
};
//------------------------------------------------------------------------------
@@ -269,7 +269,7 @@ makeRulesGivenLedger(DigestAwareReadView const& ledger, Rules const& current);
Rules
makeRulesGivenLedger(
DigestAwareReadView const& ledger,
std::unordered_set<uint256, beast::uhash<>> const& presets);
std::unordered_set<uint256, beast::Uhash<>> const& presets);
} // namespace xrpl

View File

@@ -20,10 +20,10 @@ public:
private:
enum class Action {
cache,
erase,
insert,
modify,
Cache,
Erase,
Insert,
Modify,
};
using items_t = std::map<key_type, std::pair<Action, std::shared_ptr<SLE>>>;

View File

@@ -43,19 +43,19 @@ public:
[[nodiscard]] std::shared_ptr<SLE const>
read(Keylet const& k) const override;
[[nodiscard]] std::unique_ptr<sles_type::iter_base>
[[nodiscard]] std::unique_ptr<SlesType::iter_base>
slesBegin() const override;
[[nodiscard]] std::unique_ptr<sles_type::iter_base>
[[nodiscard]] std::unique_ptr<SlesType::iter_base>
slesEnd() const override;
[[nodiscard]] std::unique_ptr<sles_type::iter_base>
[[nodiscard]] std::unique_ptr<SlesType::iter_base>
slesUpperBound(uint256 const& key) const override;
[[nodiscard]] std::unique_ptr<txs_type::iter_base>
[[nodiscard]] std::unique_ptr<TxsType::iter_base>
txsBegin() const override;
[[nodiscard]] std::unique_ptr<txs_type::iter_base>
[[nodiscard]] std::unique_ptr<TxsType::iter_base>
txsEnd() const override;
[[nodiscard]] bool

View File

@@ -19,16 +19,16 @@ public:
// Initial size for the monotonic_buffer_resource used for allocations
// The size was chosen from the old `qalloc` code (which this replaces).
// It is unclear how the size initially chosen in qalloc.
static constexpr size_t initialBufferSize = kilobytes(256);
static constexpr size_t kINITIAL_BUFFER_SIZE = kilobytes(256);
RawStateTable()
: monotonic_resource_{
std::make_unique<boost::container::pmr::monotonic_buffer_resource>(initialBufferSize)}
: monotonic_resource_{std::make_unique<boost::container::pmr::monotonic_buffer_resource>(
kINITIAL_BUFFER_SIZE)}
, items_{monotonic_resource_.get()} {};
RawStateTable(RawStateTable const& rhs)
: monotonic_resource_{
std::make_unique<boost::container::pmr::monotonic_buffer_resource>(initialBufferSize)}
: monotonic_resource_{std::make_unique<boost::container::pmr::monotonic_buffer_resource>(
kINITIAL_BUFFER_SIZE)}
, items_{rhs.items_, monotonic_resource_.get()}
, dropsDestroyed_{rhs.dropsDestroyed_} {};
@@ -63,31 +63,31 @@ public:
void
destroyXRP(XRPAmount const& fee);
[[nodiscard]] std::unique_ptr<ReadView::sles_type::iter_base>
[[nodiscard]] std::unique_ptr<ReadView::SlesType::iter_base>
slesBegin(ReadView const& base) const;
[[nodiscard]] std::unique_ptr<ReadView::sles_type::iter_base>
[[nodiscard]] std::unique_ptr<ReadView::SlesType::iter_base>
slesEnd(ReadView const& base) const;
[[nodiscard]] std::unique_ptr<ReadView::sles_type::iter_base>
[[nodiscard]] std::unique_ptr<ReadView::SlesType::iter_base>
slesUpperBound(ReadView const& base, uint256 const& key) const;
private:
enum class Action {
erase,
insert,
replace,
Erase,
Insert,
Replace,
};
class sles_iter_impl;
struct sleAction
struct SleAction
{
Action action;
std::shared_ptr<SLE> sle;
// Constructor needed for emplacement in std::map
sleAction(Action action_, std::shared_ptr<SLE> const& sle_) : action(action_), sle(sle_)
SleAction(Action action, std::shared_ptr<SLE> const& sle) : action(action), sle(sle)
{
}
};
@@ -96,9 +96,9 @@ private:
// functions b/c clang does not support pmr yet (as-of 9/2020)
using items_t = std::map<
key_type,
sleAction,
SleAction,
std::less<key_type>,
boost::container::pmr::polymorphic_allocator<std::pair<key_type const, sleAction>>>;
boost::container::pmr::polymorphic_allocator<std::pair<key_type const, SleAction>>>;
// monotonic_resource_ must outlive `items_`. Make a pointer so it may be
// easily moved.
std::unique_ptr<boost::container::pmr::monotonic_buffer_resource> monotonic_resource_;

View File

@@ -53,7 +53,7 @@ public:
"ReadViewFwdRange move and move assign constructors should be "
"noexcept");
class iterator
class Iterator
{
public:
using value_type = ValueType;
@@ -66,25 +66,25 @@ public:
using iterator_category = std::forward_iterator_tag;
iterator() = default;
Iterator() = default;
iterator(iterator const& other);
iterator(iterator&& other) noexcept;
Iterator(Iterator const& other);
Iterator(Iterator&& other) noexcept;
// Used by the implementation
explicit iterator(ReadView const* view, std::unique_ptr<iter_base> impl);
explicit Iterator(ReadView const* view, std::unique_ptr<iter_base> impl);
iterator&
operator=(iterator const& other);
Iterator&
operator=(Iterator const& other);
iterator&
operator=(iterator&& other) noexcept;
Iterator&
operator=(Iterator&& other) noexcept;
bool
operator==(iterator const& other) const;
operator==(Iterator const& other) const;
bool
operator!=(iterator const& other) const;
operator!=(Iterator const& other) const;
// Can throw
reference
@@ -94,10 +94,10 @@ public:
pointer
operator->() const;
iterator&
Iterator&
operator++();
iterator
Iterator
operator++(int);
private:
@@ -106,10 +106,10 @@ public:
std::optional<value_type> mutable cache_;
};
static_assert(std::is_nothrow_move_constructible<iterator>{}, "");
static_assert(std::is_nothrow_move_assignable<iterator>{}, "");
static_assert(std::is_nothrow_move_constructible<Iterator>{}, "");
static_assert(std::is_nothrow_move_assignable<Iterator>{}, "");
using const_iterator = iterator;
using const_iterator = Iterator;
using value_type = ValueType;

View File

@@ -4,19 +4,19 @@ namespace xrpl {
namespace detail {
template <class ValueType>
ReadViewFwdRange<ValueType>::iterator::iterator(iterator const& other)
ReadViewFwdRange<ValueType>::Iterator::Iterator(Iterator const& other)
: view_(other.view_), impl_(other.impl_ ? other.impl_->copy() : nullptr), cache_(other.cache_)
{
}
template <class ValueType>
ReadViewFwdRange<ValueType>::iterator::iterator(iterator&& other) noexcept
ReadViewFwdRange<ValueType>::Iterator::Iterator(Iterator&& other) noexcept
: view_(other.view_), impl_(std::move(other.impl_)), cache_(std::move(other.cache_))
{
}
template <class ValueType>
ReadViewFwdRange<ValueType>::iterator::iterator(
ReadViewFwdRange<ValueType>::Iterator::Iterator(
ReadView const* view,
std::unique_ptr<iter_base> impl)
: view_(view), impl_(std::move(impl))
@@ -25,7 +25,7 @@ ReadViewFwdRange<ValueType>::iterator::iterator(
template <class ValueType>
auto
ReadViewFwdRange<ValueType>::iterator::operator=(iterator const& other) -> iterator&
ReadViewFwdRange<ValueType>::Iterator::operator=(Iterator const& other) -> Iterator&
{
if (this != &other)
{
@@ -38,7 +38,7 @@ ReadViewFwdRange<ValueType>::iterator::operator=(iterator const& other) -> itera
template <class ValueType>
auto
ReadViewFwdRange<ValueType>::iterator::operator=(iterator&& other) noexcept -> iterator&
ReadViewFwdRange<ValueType>::Iterator::operator=(Iterator&& other) noexcept -> Iterator&
{
if (this != &other)
{
@@ -52,7 +52,7 @@ ReadViewFwdRange<ValueType>::iterator::operator=(iterator&& other) noexcept -> i
template <class ValueType>
bool
ReadViewFwdRange<ValueType>::iterator::operator==(iterator const& other) const
ReadViewFwdRange<ValueType>::Iterator::operator==(Iterator const& other) const
{
XRPL_ASSERT(
view_ == other.view_,
@@ -67,14 +67,14 @@ ReadViewFwdRange<ValueType>::iterator::operator==(iterator const& other) const
template <class ValueType>
bool
ReadViewFwdRange<ValueType>::iterator::operator!=(iterator const& other) const
ReadViewFwdRange<ValueType>::Iterator::operator!=(Iterator const& other) const
{
return !(*this == other);
}
template <class ValueType>
auto
ReadViewFwdRange<ValueType>::iterator::operator*() const -> reference
ReadViewFwdRange<ValueType>::Iterator::operator*() const -> reference
{
if (!cache_)
cache_ = impl_->dereference();
@@ -83,14 +83,14 @@ ReadViewFwdRange<ValueType>::iterator::operator*() const -> reference
template <class ValueType>
auto
ReadViewFwdRange<ValueType>::iterator::operator->() const -> pointer
ReadViewFwdRange<ValueType>::Iterator::operator->() const -> pointer
{
return &**this;
}
template <class ValueType>
auto
ReadViewFwdRange<ValueType>::iterator::operator++() -> iterator&
ReadViewFwdRange<ValueType>::Iterator::operator++() -> Iterator&
{
impl_->increment();
cache_.reset();
@@ -99,9 +99,9 @@ ReadViewFwdRange<ValueType>::iterator::operator++() -> iterator&
template <class ValueType>
auto
ReadViewFwdRange<ValueType>::iterator::operator++(int) -> iterator
ReadViewFwdRange<ValueType>::Iterator::operator++(int) -> Iterator
{
iterator prev(view_, impl_->copy());
Iterator prev(view_, impl_->copy());
prev.cache_ = std::move(cache_);
++(*this);
return prev;

View File

@@ -25,11 +25,11 @@ namespace detail {
Number
reduceOffer(auto const& amount)
{
static Number const reducedOfferPct(9999, -4);
static Number const kREDUCED_OFFER_PCT(9999, -4);
// Make sure the result is always less than amount or zero.
NumberRoundModeGuard const mg(Number::rounding_mode::towards_zero);
return amount * reducedOfferPct;
NumberRoundModeGuard const mg(Number::RoundingMode::TowardsZero);
return amount * kREDUCED_OFFER_PCT;
}
} // namespace detail
@@ -177,10 +177,10 @@ getAMMOfferStartWithTakerGets(
Quality const& targetQuality,
std::uint16_t const& tfee)
{
if (targetQuality.rate() == beast::zero)
if (targetQuality.rate() == beast::kZERO)
return std::nullopt;
NumberRoundModeGuard const mg(Number::rounding_mode::to_nearest);
NumberRoundModeGuard const mg(Number::RoundingMode::ToNearest);
auto const f = feeMult(tfee);
auto const a = 1;
auto const b = pool.in * (1 - 1 / f) / targetQuality.rate() - 2 * pool.out;
@@ -202,7 +202,7 @@ getAMMOfferStartWithTakerGets(
// Round downward to minimize the offer and to maximize the quality.
// This has the most impact when takerGets is XRP.
auto const takerGets =
toAmount<TOut>(getAsset(pool.out), nTakerGetsProposed, Number::rounding_mode::downward);
toAmount<TOut>(getAsset(pool.out), nTakerGetsProposed, Number::RoundingMode::Downward);
return TAmounts<TIn, TOut>{swapAssetOut(pool, takerGets, tfee), takerGets};
};
@@ -244,10 +244,10 @@ getAMMOfferStartWithTakerPays(
Quality const& targetQuality,
std::uint16_t tfee)
{
if (targetQuality.rate() == beast::zero)
if (targetQuality.rate() == beast::kZERO)
return std::nullopt;
NumberRoundModeGuard const mg(Number::rounding_mode::to_nearest);
NumberRoundModeGuard const mg(Number::RoundingMode::ToNearest);
auto const f = feeMult(tfee);
auto const& a = f;
auto const b = pool.in * (1 + f);
@@ -269,7 +269,7 @@ getAMMOfferStartWithTakerPays(
// Round downward to minimize the offer and to maximize the quality.
// This has the most impact when takerPays is XRP.
auto const takerPays =
toAmount<TIn>(getAsset(pool.in), nTakerPaysProposed, Number::rounding_mode::downward);
toAmount<TIn>(getAsset(pool.in), nTakerPaysProposed, Number::RoundingMode::Downward);
return TAmounts<TIn, TOut>{takerPays, swapAssetIn(pool, takerPays, tfee)};
};
@@ -342,7 +342,7 @@ changeSpotPriceQuality(
return std::nullopt;
}
auto const takerPays =
toAmount<TIn>(getAsset(pool.in), nTakerPays, Number::rounding_mode::upward);
toAmount<TIn>(getAsset(pool.in), nTakerPays, Number::RoundingMode::Upward);
// should not fail
if (auto amounts = TAmounts<TIn, TOut>{takerPays, swapAssetIn(pool, takerPays, tfee)};
Quality{amounts} < quality &&
@@ -446,34 +446,34 @@ swapAssetIn(TAmounts<TIn, TOut> const& pool, TIn const& assetIn, std::uint16_t t
// 1-fee
// maximize:
// fee
saveNumberRoundMode const _{Number::getround()};
SaveNumberRoundMode const _{Number::getround()};
Number::setround(Number::rounding_mode::upward);
Number::setround(Number::RoundingMode::Upward);
auto const numerator = pool.in * pool.out;
auto const fee = getFee(tfee);
Number::setround(Number::rounding_mode::downward);
Number::setround(Number::RoundingMode::Downward);
auto const denom = pool.in + assetIn * (1 - fee);
if (denom.signum() <= 0)
return toAmount<TOut>(getAsset(pool.out), 0);
Number::setround(Number::rounding_mode::upward);
Number::setround(Number::RoundingMode::Upward);
auto const ratio = numerator / denom;
Number::setround(Number::rounding_mode::downward);
Number::setround(Number::RoundingMode::Downward);
auto const swapOut = pool.out - ratio;
if (swapOut.signum() < 0)
return toAmount<TOut>(getAsset(pool.out), 0);
return toAmount<TOut>(getAsset(pool.out), swapOut, Number::rounding_mode::downward);
return toAmount<TOut>(getAsset(pool.out), swapOut, Number::RoundingMode::Downward);
}
return toAmount<TOut>(
getAsset(pool.out),
pool.out - (pool.in * pool.out) / (pool.in + assetIn * feeMult(tfee)),
Number::rounding_mode::downward);
Number::RoundingMode::Downward);
}
/** Swap assetOut out of the pool and swap in a proportional amount
@@ -508,38 +508,38 @@ swapAssetOut(TAmounts<TIn, TOut> const& pool, TOut const& assetOut, std::uint16_
// maximize:
// tfee/100000
saveNumberRoundMode const _{Number::getround()};
SaveNumberRoundMode const _{Number::getround()};
Number::setround(Number::rounding_mode::upward);
Number::setround(Number::RoundingMode::Upward);
auto const numerator = pool.in * pool.out;
Number::setround(Number::rounding_mode::downward);
Number::setround(Number::RoundingMode::Downward);
auto const denom = pool.out - assetOut;
if (denom.signum() <= 0)
{
return toMaxAmount<TIn>(getAsset(pool.in));
}
Number::setround(Number::rounding_mode::upward);
Number::setround(Number::RoundingMode::Upward);
auto const ratio = numerator / denom;
auto const numerator2 = ratio - pool.in;
auto const fee = getFee(tfee);
Number::setround(Number::rounding_mode::downward);
Number::setround(Number::RoundingMode::Downward);
auto const feeMult = 1 - fee;
Number::setround(Number::rounding_mode::upward);
Number::setround(Number::RoundingMode::Upward);
auto const swapIn = numerator2 / feeMult;
if (swapIn.signum() < 0)
return toAmount<TIn>(getAsset(pool.in), 0);
return toAmount<TIn>(getAsset(pool.in), swapIn, Number::rounding_mode::upward);
return toAmount<TIn>(getAsset(pool.in), swapIn, Number::RoundingMode::Upward);
}
return toAmount<TIn>(
getAsset(pool.in),
((pool.in * pool.out) / (pool.out - assetOut) - pool.in) / feeMult(tfee),
Number::rounding_mode::upward);
Number::RoundingMode::Upward);
}
/** Return square of n.
@@ -589,26 +589,26 @@ Number
solveQuadraticEq(Number const& a, Number const& b, Number const& c);
STAmount
multiply(STAmount const& amount, Number const& frac, Number::rounding_mode rm);
multiply(STAmount const& amount, Number const& frac, Number::RoundingMode rm);
namespace detail {
inline Number::rounding_mode
inline Number::RoundingMode
getLPTokenRounding(IsDeposit isDeposit)
{
// Minimize on deposit, maximize on withdraw to ensure
// AMM invariant sqrt(poolAsset1 * poolAsset2) >= LPTokensBalance
return isDeposit == IsDeposit::Yes ? Number::rounding_mode::downward
: Number::rounding_mode::upward;
return isDeposit == IsDeposit::Yes ? Number::RoundingMode::Downward
: Number::RoundingMode::Upward;
}
inline Number::rounding_mode
inline Number::RoundingMode
getAssetRounding(IsDeposit isDeposit)
{
// Maximize on deposit, minimize on withdraw to ensure
// AMM invariant sqrt(poolAsset1 * poolAsset2) >= LPTokensBalance
return isDeposit == IsDeposit::Yes ? Number::rounding_mode::upward
: Number::rounding_mode::downward;
return isDeposit == IsDeposit::Yes ? Number::RoundingMode::Upward
: Number::RoundingMode::Downward;
}
} // namespace detail

View File

@@ -10,7 +10,7 @@ namespace xrpl {
bool
checkLendingProtocolDependencies(Rules const& rules, STTx const& tx);
static constexpr std::uint32_t secondsInYear = 365 * 24 * 60 * 60;
static constexpr std::uint32_t kSECONDS_IN_YEAR = 365 * 24 * 60 * 60;
Number
loanPeriodicRate(TenthBips32 interestRate, std::uint32_t paymentInterval);
@@ -19,7 +19,7 @@ loanPeriodicRate(TenthBips32 interestRate, std::uint32_t paymentInterval);
inline Number
roundPeriodicPayment(Asset const& asset, Number const& periodicPayment, std::int32_t scale)
{
return roundToAsset(asset, periodicPayment, scale, Number::rounding_mode::upward);
return roundToAsset(asset, periodicPayment, scale, Number::RoundingMode::Upward);
}
/* Represents the breakdown of amounts to be paid and changes applied to the
@@ -42,14 +42,14 @@ struct LoanPaymentParts
// The amount of principal paid that reduces the loan balance.
// This amount is subtracted from sfPrincipalOutstanding in the Loan object
// and paid to the Vault
Number principalPaid = numZero;
Number principalPaid = kNUM_ZERO;
// The total amount of interest paid to the Vault.
// This includes:
// - Tracked interest from the amortization schedule
// - Untracked interest (e.g., late payment penalty interest)
// This value is always non-negative.
Number interestPaid = numZero;
Number interestPaid = kNUM_ZERO;
// The change in the loan's total value outstanding.
// - If valueChange < 0: Loan value decreased
@@ -62,7 +62,7 @@ struct LoanPaymentParts
// - Late payments add penalty interest to the loan value
// - Early full payment may increase or decrease the loan value based on
// terms
Number valueChange = numZero;
Number valueChange = kNUM_ZERO;
/* The total amount of fees paid to the Broker.
* This includes:
@@ -70,7 +70,7 @@ struct LoanPaymentParts
* - Untracked fees (e.g., late payment fees, service fees, origination
* fees) This value is always non-negative.
*/
Number feePaid = numZero;
Number feePaid = kNUM_ZERO;
LoanPaymentParts&
operator+=(LoanPaymentParts const& other);
@@ -161,7 +161,7 @@ adjustImpreciseNumber(
{
value = roundToAsset(asset, value + adjustment, vaultScale);
if (*value < beast::zero)
if (*value < beast::kZERO)
value = 0;
}
@@ -169,7 +169,7 @@ inline int
getAssetsTotalScale(SLE::const_ref vaultSle)
{
if (!vaultSle)
return Number::minExponent - 1; // LCOV_EXCL_LINE
return Number::kMIN_EXPONENT - 1; // LCOV_EXCL_LINE
return scale(vaultSle->at(sfAssetsTotal), vaultSle->at(sfAsset));
}
@@ -222,7 +222,7 @@ namespace detail {
// These classes and functions should only be accessed by LendingHelper
// functions and unit tests
enum class PaymentSpecialCase { none, final, extra };
enum class PaymentSpecialCase { None, Final, Extra };
/* Represents a single loan payment component parts.
@@ -258,7 +258,7 @@ struct PaymentComponents
// - none: Regular scheduled payment
// - final: The last payment that closes out the loan
// - extra: An additional payment beyond the regular schedule (overpayment)
PaymentSpecialCase specialCase = PaymentSpecialCase::none;
PaymentSpecialCase specialCase = PaymentSpecialCase::None;
// Calculates the tracked interest portion of this payment.
// This is derived from the other components as:
@@ -310,7 +310,7 @@ struct ExtendedPaymentComponents : public PaymentComponents
// borrower is sufficient to cover all components of the payment.
Number totalDue;
ExtendedPaymentComponents(PaymentComponents const& p, Number fee, Number interest = numZero)
ExtendedPaymentComponents(PaymentComponents const& p, Number fee, Number interest = kNUM_ZERO)
: PaymentComponents(p)
, untrackedManagementFee(fee)
, untrackedInterest(interest)
@@ -462,7 +462,7 @@ isRounded(Asset const& asset, Number const& value, std::int32_t scale);
// regular, late, and full are mutually exclusive.
// overpayment is an "add on" to a regular payment, and follows that path with
// potential extra work at the end.
enum class LoanPaymentType { regular = 0, late, full, overpayment };
enum class LoanPaymentType { Regular = 0, Late, Full, Overpayment };
Expected<LoanPaymentParts, TER>
loanMakePayment(

View File

@@ -30,8 +30,8 @@ struct TokenAndPage
STObject token;
std::shared_ptr<SLE> page;
TokenAndPage(STObject token_, std::shared_ptr<SLE> page_)
: token(std::move(token_)), page(std::move(page_))
TokenAndPage(STObject token, std::shared_ptr<SLE> page)
: token(std::move(token)), page(std::move(page))
{
}
};
@@ -92,7 +92,7 @@ tokenOfferCreatePreflight(
std::uint16_t nftFlags,
Rules const& rules,
std::optional<AccountID> const& owner = std::nullopt,
std::uint32_t txFlags = tfSellNFToken);
std::uint32_t txFlags = kTF_SELL_NF_TOKEN);
/** Preclaim checks shared by NFTokenCreateOffer and NFTokenMint */
TER
@@ -106,7 +106,7 @@ tokenOfferCreatePreclaim(
std::uint16_t xferFee,
beast::Journal j,
std::optional<AccountID> const& owner = std::nullopt,
std::uint32_t txFlags = tfSellNFToken);
std::uint32_t txFlags = kTF_SELL_NF_TOKEN);
/** doApply implementation shared by NFTokenCreateOffer and NFTokenMint */
TER
@@ -120,7 +120,7 @@ tokenOfferCreateApply(
uint256 const& nftokenID,
XRPAmount const& priorBalance,
beast::Journal j,
std::uint32_t txFlags = tfSellNFToken);
std::uint32_t txFlags = kTF_SELL_NF_TOKEN);
TER
checkTrustlineAuthorized(

View File

@@ -118,7 +118,7 @@ isDeepFrozen(
[[nodiscard]] inline TER
checkDeepFrozen(ReadView const& view, AccountID const& account, Issue const& issue)
{
return isDeepFrozen(view, account, issue) ? (TER)tecFROZEN : (TER)tesSUCCESS;
return isDeepFrozen(view, account, issue) ? (TER)TecFrozen : (TER)TesSuccess;
}
//------------------------------------------------------------------------------

View File

@@ -21,13 +21,13 @@ namespace xrpl {
//------------------------------------------------------------------------------
/** Controls the treatment of frozen account balances */
enum class FreezeHandling { fhIGNORE_FREEZE, fhZERO_IF_FROZEN };
enum class FreezeHandling { FhIgnoreFreeze, FhZeroIfFrozen };
/** Controls the treatment of unauthorized MPT balances */
enum class AuthHandling { ahIGNORE_AUTH, ahZERO_IF_UNAUTHORIZED };
enum class AuthHandling { AhIgnoreAuth, AhZeroIfUnauthorized };
/** Controls whether to include the account's full spendable balance */
enum class SpendableHandling { shSIMPLE_BALANCE, shFULL_BALANCE };
enum class SpendableHandling { ShSimpleBalance, ShFullBalance };
enum class WaiveTransferFee : bool { No = false, Yes };
@@ -135,7 +135,7 @@ accountHolds(
AccountID const& issuer,
FreezeHandling zeroIfFrozen,
beast::Journal j,
SpendableHandling includeFullBalance = SpendableHandling::shSIMPLE_BALANCE);
SpendableHandling includeFullBalance = SpendableHandling::ShSimpleBalance);
[[nodiscard]] STAmount
accountHolds(
@@ -144,7 +144,7 @@ accountHolds(
Issue const& issue,
FreezeHandling zeroIfFrozen,
beast::Journal j,
SpendableHandling includeFullBalance = SpendableHandling::shSIMPLE_BALANCE);
SpendableHandling includeFullBalance = SpendableHandling::ShSimpleBalance);
[[nodiscard]] STAmount
accountHolds(
@@ -154,7 +154,7 @@ accountHolds(
FreezeHandling zeroIfFrozen,
AuthHandling zeroIfUnauthorized,
beast::Journal j,
SpendableHandling includeFullBalance = SpendableHandling::shSIMPLE_BALANCE);
SpendableHandling includeFullBalance = SpendableHandling::ShSimpleBalance);
[[nodiscard]] STAmount
accountHolds(
@@ -164,7 +164,7 @@ accountHolds(
FreezeHandling zeroIfFrozen,
AuthHandling zeroIfUnauthorized,
beast::Journal j,
SpendableHandling includeFullBalance = SpendableHandling::shSIMPLE_BALANCE);
SpendableHandling includeFullBalance = SpendableHandling::ShSimpleBalance);
// Returns the amount an account can spend of the currency type saDefault, or
// returns saDefault if this account is the issuer of the currency in

View File

@@ -113,7 +113,7 @@ public:
@see import
*/
virtual void
for_each(std::function<void(std::shared_ptr<NodeObject>)> f) = 0;
forEach(std::function<void(std::shared_ptr<NodeObject>)> f) = 0;
/** Estimate the number of write operations pending. */
virtual int

View File

@@ -110,7 +110,7 @@ public:
fetchNodeObject(
uint256 const& hash,
std::uint32_t ledgerSeq = 0,
FetchType fetchType = FetchType::synchronous,
FetchType fetchType = FetchType::Synchronous,
bool duplicate = false);
/** Fetch an object without waiting.
@@ -266,7 +266,7 @@ private:
@see import
*/
virtual void
for_each(std::function<void(std::shared_ptr<NodeObject>)> f) = 0;
forEach(std::function<void(std::shared_ptr<NodeObject>)> f) = 0;
void
threadEntry();

View File

@@ -10,11 +10,11 @@ namespace xrpl {
/** The types of node objects. */
enum class NodeObjectType : std::uint32_t {
hotUNKNOWN = 0,
hotLEDGER = 1,
hotACCOUNT_NODE = 3,
hotTRANSACTION_NODE = 4,
hotDUMMY = 512 // an invalid or missing object
HotUnknown = 0,
HotLedger = 1,
HotAccountNode = 3,
HotTransactionNode = 4,
HotDummy = 512 // an invalid or missing object
};
/** A simple object that the Ledger uses to store entries.
@@ -29,7 +29,7 @@ enum class NodeObjectType : std::uint32_t {
class NodeObject : public CountedObject<NodeObject>
{
public:
static constexpr std::size_t keyBytes = 32;
static constexpr std::size_t kEY_BYTES = 32;
private:
// This hack is used to make the constructor effectively private
@@ -71,9 +71,9 @@ public:
getData() const;
private:
NodeObjectType const mType;
uint256 const mHash;
Blob const mData;
NodeObjectType const mType_;
uint256 const mHash_;
Blob const mData_;
};
} // namespace xrpl

View File

@@ -6,12 +6,12 @@
namespace xrpl::NodeStore {
enum class FetchType { synchronous, async };
enum class FetchType { Synchronous, Async };
/** Contains information about a fetch operation. */
struct FetchReport
{
explicit FetchReport(FetchType fetchType_) : fetchType(fetchType_)
explicit FetchReport(FetchType fetchType) : fetchType(fetchType)
{
}

View File

@@ -12,24 +12,24 @@ enum {
// This is only used to pre-allocate the array for
// batch objects and does not affect the amount written.
//
batchWritePreallocationSize = 256,
BatchWritePreallocationSize = 256,
// This sets a limit on the maximum number of writes
// in a batch. Actual usage can be twice this since
// we have a new batch growing as we write the old.
//
batchWriteLimitSize = 65536
BatchWriteLimitSize = 65536
};
/** Return codes from Backend operations. */
enum class Status {
ok = 0,
notFound = 1,
dataCorrupt = 2,
unknown = 3,
backendError = 4,
Ok = 0,
NotFound = 1,
DataCorrupt = 2,
Unknown = 3,
BackendError = 4,
customCode = 100
CustomCode = 100
};
/** A batch of NodeObjects to write at once. */

Some files were not shown because too many files have changed in this diff Show More