Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::chain::resource_limits::impl Namespace Reference

Classes

struct  exponential_decay_accumulator
 
struct  exponential_moving_average_accumulator
 
struct  ratio
 

Functions

template<typename T >
ratio< Tmake_ratio (T n, T d)
 
template<typename T >
T operator* (T value, const ratio< T > &r)
 
template<typename UnsignedIntType >
constexpr UnsignedIntType integer_divide_ceil (UnsignedIntType num, UnsignedIntType den)
 
template<typename LesserIntType , typename GreaterIntType >
constexpr auto downgrade_cast (GreaterIntType val) -> std::enable_if_t< is_valid_downgrade_cast< LesserIntType, GreaterIntType > &&std::is_signed< LesserIntType >::value==std::is_signed< GreaterIntType >::value, LesserIntType >
 

Variables

template<typename LesserIntType , typename GreaterIntType >
constexpr bool is_valid_downgrade_cast
 

Function Documentation

◆ downgrade_cast()

template<typename LesserIntType , typename GreaterIntType >
auto sysio::chain::resource_limits::impl::downgrade_cast ( GreaterIntType val) -> std::enable_if_t<is_valid_downgrade_cast<LesserIntType,GreaterIntType> && std::is_signed<LesserIntType>::value == std::is_signed<GreaterIntType>::value, LesserIntType>
constexpr

Specialization for Signedness matching integer types

Specialization for Signedness mismatching integer types

Definition at line 40 of file resource_limits_private.hpp.

42 {
43 const GreaterIntType max = std::numeric_limits<LesserIntType>::max();
44 const GreaterIntType min = std::numeric_limits<LesserIntType>::min();
45 SYS_ASSERT( val >= min && val <= max, rate_limiting_state_inconsistent, "Casting a higher bit integer value ${v} to a lower bit integer value which cannot contain the value, valid range is [${min}, ${max}]", ("v", val)("min", min)("max",max) );
46 return LesserIntType(val);
47 };
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
Definition exceptions.hpp:7
const T & min(const T &a, const T &b)
Definition utility.hpp:140
Here is the call graph for this function:
Here is the caller graph for this function:

◆ integer_divide_ceil()

template<typename UnsignedIntType >
UnsignedIntType sysio::chain::resource_limits::impl::integer_divide_ceil ( UnsignedIntType num,
UnsignedIntType den )
constexpr

Definition at line 25 of file resource_limits_private.hpp.

25 {
26 return (num / den) + ((num % den) > 0 ? 1 : 0);
27 }
Here is the caller graph for this function:

◆ make_ratio()

template<typename T >
ratio< T > sysio::chain::resource_limits::impl::make_ratio ( T n,
T d )

Definition at line 14 of file resource_limits_private.hpp.

Here is the caller graph for this function:

◆ operator*()

template<typename T >
T sysio::chain::resource_limits::impl::operator* ( T value,
const ratio< T > & r )

Definition at line 19 of file resource_limits_private.hpp.

19 {
20 SYS_ASSERT(r.numerator == T(0) || std::numeric_limits<T>::max() / r.numerator >= value, rate_limiting_state_inconsistent, "Usage exceeds maximum value representable after extending for precision");
21 return (value * r.numerator) / r.denominator;
22 }
const mie::Vuint & r
Definition bn.cpp:28
#define value
Definition pkcs11.h:157
#define T(meth, val, expected)

Variable Documentation

◆ is_valid_downgrade_cast

template<typename LesserIntType , typename GreaterIntType >
bool sysio::chain::resource_limits::impl::is_valid_downgrade_cast
constexpr
Initial value:
=
std::is_integral<LesserIntType>::value &&
std::is_integral<GreaterIntType>::value &&
(std::numeric_limits<LesserIntType>::max() <= std::numeric_limits<GreaterIntType>::max())

Definition at line 31 of file resource_limits_private.hpp.