20 #ifndef RIPPLE_SHAMAP_SHAMAPITEM_H_INCLUDED
21 #define RIPPLE_SHAMAP_SHAMAPITEM_H_INCLUDED
23 #include <ripple/basics/ByteUtilities.h>
24 #include <ripple/basics/CountedObject.h>
25 #include <ripple/basics/SlabAllocator.h>
26 #include <ripple/basics/Slice.h>
27 #include <ripple/basics/base_uint.h>
28 #include <boost/smart_ptr/intrusive_ptr.hpp>
46 friend boost::intrusive_ptr<SHAMapItem>
101 return reinterpret_cast<std::uint8_t const*
>(
this) +
sizeof(*
this);
117 inline SlabAllocatorSet<SHAMapItem>
slabber({
136 LogicError(
"SHAMapItem: the reference count is 0!");
149 if constexpr (!std::is_trivially_destructible_v<SHAMapItem>)
159 inline boost::intrusive_ptr<SHAMapItem>
162 assert(data.size() <= megabytes<std::size_t>(16));
175 return {
new (raw)
SHAMapItem{tag, data},
false};
178 static_assert(
alignof(SHAMapItem) != 40);
179 static_assert(
alignof(SHAMapItem) == 8 ||
alignof(SHAMapItem) == 4);
181 inline boost::intrusive_ptr<SHAMapItem>
friend void intrusive_ptr_add_ref(SHAMapItem const *x)
void const * data() const
Tracks the number of instances of an object.
An immutable linear range of bytes.
boost::intrusive_ptr< SHAMapItem > make_shamapitem(uint256 const &tag, Slice data)
SHAMapItem & operator=(SHAMapItem const &other)=delete
void intrusive_ptr_add_ref(SHAMapItem const *x)
friend boost::intrusive_ptr< SHAMapItem > make_shamapitem(uint256 const &tag, Slice data)
SlabAllocatorSet< SHAMapItem > slabber({ { 128, megabytes(std::size_t(60)) }, { 192, megabytes(std::size_t(46)) }, { 272, megabytes(std::size_t(60)) }, { 384, megabytes(std::size_t(56)) }, { 564, megabytes(std::size_t(40)) }, { 772, megabytes(std::size_t(46)) }, { 1052, megabytes(std::size_t(60)) }, })
uint256 const & key() const
const std::uint32_t size_
constexpr auto megabytes(T value) noexcept
friend void intrusive_ptr_release(SHAMapItem const *x)
std::atomic< std::uint32_t > refcount_
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
void LogicError(std::string const &how) noexcept
Called when faulty logic causes a broken invariant.
void intrusive_ptr_release(SHAMapItem const *x)
SHAMapItem(uint256 const &tag, Slice data)