mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-26 21:45:50 +00:00
Remove trailing spaces.
This commit is contained in:
committed by
Nik Bougalis
parent
1883b40083
commit
b783e353c4
@@ -194,7 +194,7 @@ namespace detail
|
|||||||
{
|
{
|
||||||
|
|
||||||
/** Specialized helper class template for swapping bytes.
|
/** Specialized helper class template for swapping bytes.
|
||||||
|
|
||||||
Normally you won't use this directly, use the helper function
|
Normally you won't use this directly, use the helper function
|
||||||
byteSwap instead. You can specialize this class for your
|
byteSwap instead. You can specialize this class for your
|
||||||
own user defined types, as was done for uint24.
|
own user defined types, as was done for uint24.
|
||||||
@@ -204,7 +204,7 @@ namespace detail
|
|||||||
template <typename IntegralType>
|
template <typename IntegralType>
|
||||||
struct SwapBytes
|
struct SwapBytes
|
||||||
{
|
{
|
||||||
inline IntegralType operator() (IntegralType value) const noexcept
|
inline IntegralType operator() (IntegralType value) const noexcept
|
||||||
{
|
{
|
||||||
return ByteOrder::swap (value);
|
return ByteOrder::swap (value);
|
||||||
}
|
}
|
||||||
@@ -215,7 +215,7 @@ struct SwapBytes
|
|||||||
template <>
|
template <>
|
||||||
struct SwapBytes <std::int16_t>
|
struct SwapBytes <std::int16_t>
|
||||||
{
|
{
|
||||||
inline std::int16_t operator() (std::int16_t value) const noexcept
|
inline std::int16_t operator() (std::int16_t value) const noexcept
|
||||||
{
|
{
|
||||||
return static_cast <std::int16_t> (ByteOrder::swap (static_cast <std::uint16_t> (value)));
|
return static_cast <std::int16_t> (ByteOrder::swap (static_cast <std::uint16_t> (value)));
|
||||||
}
|
}
|
||||||
@@ -224,7 +224,7 @@ struct SwapBytes <std::int16_t>
|
|||||||
template <>
|
template <>
|
||||||
struct SwapBytes <std::int32_t>
|
struct SwapBytes <std::int32_t>
|
||||||
{
|
{
|
||||||
inline std::int32_t operator() (std::int32_t value) const noexcept
|
inline std::int32_t operator() (std::int32_t value) const noexcept
|
||||||
{
|
{
|
||||||
return static_cast <std::int32_t> (ByteOrder::swap (static_cast <std::uint32_t> (value)));
|
return static_cast <std::int32_t> (ByteOrder::swap (static_cast <std::uint32_t> (value)));
|
||||||
}
|
}
|
||||||
@@ -233,7 +233,7 @@ struct SwapBytes <std::int32_t>
|
|||||||
template <>
|
template <>
|
||||||
struct SwapBytes <std::int64_t>
|
struct SwapBytes <std::int64_t>
|
||||||
{
|
{
|
||||||
inline std::int64_t operator() (std::int64_t value) const noexcept
|
inline std::int64_t operator() (std::int64_t value) const noexcept
|
||||||
{
|
{
|
||||||
return static_cast <std::int64_t> (ByteOrder::swap (static_cast <std::uint64_t> (value)));
|
return static_cast <std::int64_t> (ByteOrder::swap (static_cast <std::uint64_t> (value)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,5 +56,5 @@
|
|||||||
|
|
||||||
// Suffix
|
// Suffix
|
||||||
#include <beast/config/Suffix.h>
|
#include <beast/config/Suffix.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#define BEAST_MEMORY_H_INCLUDED
|
#define BEAST_MEMORY_H_INCLUDED
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include <beast/Config.h>
|
#include <beast/Config.h>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
@@ -86,7 +86,7 @@ Type* createCopyIfNotNull (const Type* pointer)
|
|||||||
|
|
||||||
ScopedAutoReleasePool(ScopedAutoReleasePool const&) = delete;
|
ScopedAutoReleasePool(ScopedAutoReleasePool const&) = delete;
|
||||||
ScopedAutoReleasePool& operator= (ScopedAutoReleasePool const&) = delete;
|
ScopedAutoReleasePool& operator= (ScopedAutoReleasePool const&) = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void* pool;
|
void* pool;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ is_short_read (boost::system::error_code const& ec)
|
|||||||
return (ec.category() == boost::asio::error::get_ssl_category())
|
return (ec.category() == boost::asio::error::get_ssl_category())
|
||||||
&& (ERR_GET_REASON(ec.value()) == SSL_R_SHORT_READ);
|
&& (ERR_GET_REASON(ec.value()) == SSL_R_SHORT_READ);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a human readable message if the error code is SSL related. */
|
/** Returns a human readable message if the error code is SSL related. */
|
||||||
std::string
|
std::string
|
||||||
asio_message(boost::system::error_code const& ec);
|
asio_message(boost::system::error_code const& ec);
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ asio_message (boost::system::error_code const& ec)
|
|||||||
+ ","
|
+ ","
|
||||||
+ boost::lexical_cast<std::string> (ERR_GET_REASON (ec.value ()))
|
+ boost::lexical_cast<std::string> (ERR_GET_REASON (ec.value ()))
|
||||||
+ ") ";
|
+ ") ";
|
||||||
|
|
||||||
//
|
//
|
||||||
char buf[errorBufferSize];
|
char buf[errorBufferSize];
|
||||||
::ERR_error_string_n (ec.value (), buf, errorBufferSize);
|
::ERR_error_string_n (ec.value (), buf, errorBufferSize);
|
||||||
error += buf;
|
error += buf;
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ private:
|
|||||||
the output sequence is empty, out_ will point to the end of
|
the output sequence is empty, out_ will point to the end of
|
||||||
the list of buffers, and out_pos_ and out_end_ will be 0:
|
the list of buffers, and out_pos_ and out_end_ will be 0:
|
||||||
|
|
||||||
|
|
||||||
|<------+------------------>| out_ == list_.end()
|
|<------+------------------>| out_ == list_.end()
|
||||||
in_pos_ out_pos_ == 0
|
in_pos_ out_pos_ == 0
|
||||||
out_end_ == 0
|
out_end_ == 0
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class error_test : public unit_test::suite
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void run ()
|
void run ()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
boost::system::error_code ec = boost::system::error_code (335544539,
|
boost::system::error_code ec = boost::system::error_code (335544539,
|
||||||
boost::asio::error::get_ssl_category ());
|
boost::asio::error::get_ssl_category ());
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ public:
|
|||||||
b.commit(10);
|
b.commit(10);
|
||||||
expect(to_str(b.data()) == "567890ABCD");
|
expect(to_str(b.data()) == "567890ABCD");
|
||||||
}
|
}
|
||||||
|
|
||||||
test_prepare();
|
test_prepare();
|
||||||
test_commit();
|
test_commit();
|
||||||
test_consume();
|
test_consume();
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
#include <beast/utility/noexcept.h>
|
#include <beast/utility/noexcept.h>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
chrono_io synopsis
|
chrono_io synopsis
|
||||||
@@ -58,7 +58,7 @@ public:
|
|||||||
|
|
||||||
explicit durationpunct(size_t refs = 0);
|
explicit durationpunct(size_t refs = 0);
|
||||||
explicit durationpunct(duration_style fmt, size_t refs = 0);
|
explicit durationpunct(duration_style fmt, size_t refs = 0);
|
||||||
|
|
||||||
bool is_symbol_name() const noexcept;
|
bool is_symbol_name() const noexcept;
|
||||||
bool is_prefix_name() const noexcept;
|
bool is_prefix_name() const noexcept;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ static double monotonicCurrentTimeInSeconds()
|
|||||||
{
|
{
|
||||||
return GetTickCount64() / 1000.0;
|
return GetTickCount64() / 1000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,7 +279,7 @@ static double monotonicCurrentTimeInSeconds()
|
|||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
static double monotonicCurrentTimeInSeconds()
|
static double monotonicCurrentTimeInSeconds()
|
||||||
{
|
{
|
||||||
struct StaticInitializer
|
struct StaticInitializer
|
||||||
@@ -291,7 +291,7 @@ static double monotonicCurrentTimeInSeconds()
|
|||||||
|
|
||||||
mach_timebase_info_data_t timebase;
|
mach_timebase_info_data_t timebase;
|
||||||
(void) mach_timebase_info (&timebase);
|
(void) mach_timebase_info (&timebase);
|
||||||
|
|
||||||
if (timebase.numer % 1000000 == 0)
|
if (timebase.numer % 1000000 == 0)
|
||||||
{
|
{
|
||||||
numerator = timebase.numer / 1000000.0;
|
numerator = timebase.numer / 1000000.0;
|
||||||
@@ -304,13 +304,13 @@ static double monotonicCurrentTimeInSeconds()
|
|||||||
//denominator = timebase.denom * (std::uint64_t) 1000000 * 1000.0;
|
//denominator = timebase.denom * (std::uint64_t) 1000000 * 1000.0;
|
||||||
denominator = timebase.denom * 1000000000.0;
|
denominator = timebase.denom * 1000000000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ratio = numerator / denominator;
|
ratio = numerator / denominator;
|
||||||
}
|
}
|
||||||
|
|
||||||
double ratio;
|
double ratio;
|
||||||
};
|
};
|
||||||
|
|
||||||
static StaticInitializer const data;
|
static StaticInitializer const data;
|
||||||
|
|
||||||
return mach_absolute_time() * data.ratio;
|
return mach_absolute_time() * data.ratio;
|
||||||
@@ -319,7 +319,7 @@ static double monotonicCurrentTimeInSeconds()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
@@ -334,7 +334,7 @@ static double monotonicCurrentTimeInSeconds()
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
@@ -349,7 +349,7 @@ static double getStartupTime()
|
|||||||
{
|
{
|
||||||
when = detail::monotonicCurrentTimeInSeconds();
|
when = detail::monotonicCurrentTimeInSeconds();
|
||||||
}
|
}
|
||||||
|
|
||||||
double when;
|
double when;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -368,7 +368,7 @@ struct StartupTimeStaticInitializer
|
|||||||
};
|
};
|
||||||
|
|
||||||
static StartupTimeStaticInitializer startupTimeStaticInitializer;
|
static StartupTimeStaticInitializer startupTimeStaticInitializer;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RelativeTime RelativeTime::fromStartup ()
|
RelativeTime RelativeTime::fromStartup ()
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ struct cyclic_iterator_base
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// cyclic_iterator_decl.hpp
|
// cyclic_iterator_decl.hpp
|
||||||
//
|
//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Portions from http://www.adp-gmbh.ch/cpp/common/base64.html
|
Portions from http://www.adp-gmbh.ch/cpp/common/base64.html
|
||||||
Copyright notice:
|
Copyright notice:
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
std::array<std::uint8_t,
|
std::array<std::uint8_t,
|
||||||
Context::digest_size>;
|
Context::digest_size>;
|
||||||
|
|
||||||
mac_facade() noexcept
|
mac_facade() noexcept
|
||||||
{
|
{
|
||||||
init(ctx_);
|
init(ctx_);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,12 +71,12 @@ struct ripemd160_context
|
|||||||
#define BEAST_RIPEMD_ROL(x, n) (((x) << (n)) | ((x) >> (32-(n))))
|
#define BEAST_RIPEMD_ROL(x, n) (((x) << (n)) | ((x) >> (32-(n))))
|
||||||
|
|
||||||
// the five basic functions F(), G() and H()
|
// the five basic functions F(), G() and H()
|
||||||
#define BEAST_RIPEMD_F(x, y, z) ((x) ^ (y) ^ (z))
|
#define BEAST_RIPEMD_F(x, y, z) ((x) ^ (y) ^ (z))
|
||||||
#define BEAST_RIPEMD_G(x, y, z) (((x) & (y)) | (~(x) & (z)))
|
#define BEAST_RIPEMD_G(x, y, z) (((x) & (y)) | (~(x) & (z)))
|
||||||
#define BEAST_RIPEMD_H(x, y, z) (((x) | ~(y)) ^ (z))
|
#define BEAST_RIPEMD_H(x, y, z) (((x) | ~(y)) ^ (z))
|
||||||
#define BEAST_RIPEMD_I(x, y, z) (((x) & (z)) | ((y) & ~(z)))
|
#define BEAST_RIPEMD_I(x, y, z) (((x) & (z)) | ((y) & ~(z)))
|
||||||
#define BEAST_RIPEMD_J(x, y, z) ((x) ^ ((y) | ~(z)))
|
#define BEAST_RIPEMD_J(x, y, z) ((x) ^ ((y) | ~(z)))
|
||||||
|
|
||||||
// the ten basic operations FF() through III()
|
// the ten basic operations FF() through III()
|
||||||
#define BEAST_RIPEMD_FF(a, b, c, d, e, x, s) { \
|
#define BEAST_RIPEMD_FF(a, b, c, d, e, x, s) { \
|
||||||
(a) += BEAST_RIPEMD_F((b), (c), (d)) + (x); \
|
(a) += BEAST_RIPEMD_F((b), (c), (d)) + (x); \
|
||||||
@@ -166,7 +166,7 @@ void ripemd_compress (ripemd160_context& ctx,
|
|||||||
BEAST_RIPEMD_FF(cc, dd, ee, aa, bb, X[13], 7);
|
BEAST_RIPEMD_FF(cc, dd, ee, aa, bb, X[13], 7);
|
||||||
BEAST_RIPEMD_FF(bb, cc, dd, ee, aa, X[14], 9);
|
BEAST_RIPEMD_FF(bb, cc, dd, ee, aa, X[14], 9);
|
||||||
BEAST_RIPEMD_FF(aa, bb, cc, dd, ee, X[15], 8);
|
BEAST_RIPEMD_FF(aa, bb, cc, dd, ee, X[15], 8);
|
||||||
|
|
||||||
// round 2
|
// round 2
|
||||||
BEAST_RIPEMD_GG(ee, aa, bb, cc, dd, X[ 7], 7);
|
BEAST_RIPEMD_GG(ee, aa, bb, cc, dd, X[ 7], 7);
|
||||||
BEAST_RIPEMD_GG(dd, ee, aa, bb, cc, X[ 4], 6);
|
BEAST_RIPEMD_GG(dd, ee, aa, bb, cc, X[ 4], 6);
|
||||||
@@ -258,7 +258,7 @@ void ripemd_compress (ripemd160_context& ctx,
|
|||||||
BEAST_RIPEMD_JJJ(aaa, bbb, ccc, ddd, eee, X[12], 6);
|
BEAST_RIPEMD_JJJ(aaa, bbb, ccc, ddd, eee, X[12], 6);
|
||||||
|
|
||||||
// parallel round 2
|
// parallel round 2
|
||||||
BEAST_RIPEMD_III(eee, aaa, bbb, ccc, ddd, X[ 6], 9);
|
BEAST_RIPEMD_III(eee, aaa, bbb, ccc, ddd, X[ 6], 9);
|
||||||
BEAST_RIPEMD_III(ddd, eee, aaa, bbb, ccc, X[11], 13);
|
BEAST_RIPEMD_III(ddd, eee, aaa, bbb, ccc, X[11], 13);
|
||||||
BEAST_RIPEMD_III(ccc, ddd, eee, aaa, bbb, X[ 3], 15);
|
BEAST_RIPEMD_III(ccc, ddd, eee, aaa, bbb, X[ 3], 15);
|
||||||
BEAST_RIPEMD_III(bbb, ccc, ddd, eee, aaa, X[ 7], 7);
|
BEAST_RIPEMD_III(bbb, ccc, ddd, eee, aaa, X[ 7], 7);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace detail {
|
|||||||
/*
|
/*
|
||||||
* Updated to C++, zedwood.com 2012
|
* Updated to C++, zedwood.com 2012
|
||||||
* Based on Olivier Gay's version
|
* Based on Olivier Gay's version
|
||||||
* See Modified BSD License below:
|
* See Modified BSD License below:
|
||||||
*
|
*
|
||||||
* FIPS 180-2 SHA-224/256/384/512 implementation
|
* FIPS 180-2 SHA-224/256/384/512 implementation
|
||||||
* Issue date: 04/30/2005
|
* Issue date: 04/30/2005
|
||||||
@@ -83,7 +83,7 @@ struct sha512_context
|
|||||||
{
|
{
|
||||||
static unsigned int const block_size = 128;
|
static unsigned int const block_size = 128;
|
||||||
static unsigned int const digest_size = 64;
|
static unsigned int const digest_size = 64;
|
||||||
|
|
||||||
unsigned int tot_len;
|
unsigned int tot_len;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
unsigned char block[2 * block_size];
|
unsigned char block[2 * block_size];
|
||||||
@@ -369,7 +369,7 @@ void init (sha512_context& ctx) noexcept
|
|||||||
ctx.h[3] = 0xa54ff53a5f1d36f1ULL;
|
ctx.h[3] = 0xa54ff53a5f1d36f1ULL;
|
||||||
ctx.h[4] = 0x510e527fade682d1ULL;
|
ctx.h[4] = 0x510e527fade682d1ULL;
|
||||||
ctx.h[5] = 0x9b05688c2b3e6c1fULL;
|
ctx.h[5] = 0x9b05688c2b3e6c1fULL;
|
||||||
ctx.h[6] = 0x1f83d9abfb41bd6bULL;
|
ctx.h[6] = 0x1f83d9abfb41bd6bULL;
|
||||||
ctx.h[7] = 0x5be0cd19137e2179ULL;
|
ctx.h[7] = 0x5be0cd19137e2179ULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,20 +55,20 @@ public:
|
|||||||
using size2 = std::index_sequence_for<int, size_t>; // generates size_t: 0,1
|
using size2 = std::index_sequence_for<int, size_t>; // generates size_t: 0,1
|
||||||
using intmix = std::integer_sequence<int, 9, 8, 7, 2>; // generates int: 9,8,7,2
|
using intmix = std::integer_sequence<int, 9, 8, 7, 2>; // generates int: 9,8,7,2
|
||||||
using sizemix = std::index_sequence<1, 1, 2, 3, 5>; // generates size_t: 1,1,2,3,5
|
using sizemix = std::index_sequence<1, 1, 2, 3, 5>; // generates size_t: 1,1,2,3,5
|
||||||
|
|
||||||
// Make sure they're what we expect
|
// Make sure they're what we expect
|
||||||
static_assert ( std::is_same <int3::value_type, int>::value, "int3 type wrong" );
|
static_assert ( std::is_same <int3::value_type, int>::value, "int3 type wrong" );
|
||||||
static_assert ( int3::static_size == 3, "int3 size wrong" );
|
static_assert ( int3::static_size == 3, "int3 size wrong" );
|
||||||
|
|
||||||
static_assert ( std::is_same <size7::value_type, size_t>::value, "size7 type wrong" );
|
static_assert ( std::is_same <size7::value_type, size_t>::value, "size7 type wrong" );
|
||||||
static_assert ( size7::static_size == 7, "size7 size wrong" );
|
static_assert ( size7::static_size == 7, "size7 size wrong" );
|
||||||
|
|
||||||
static_assert ( std::is_same <size4::value_type, size_t>::value, "size4 type wrong" );
|
static_assert ( std::is_same <size4::value_type, size_t>::value, "size4 type wrong" );
|
||||||
static_assert ( size4::static_size == 4, "size4 size wrong" );
|
static_assert ( size4::static_size == 4, "size4 size wrong" );
|
||||||
|
|
||||||
static_assert ( std::is_same <size2::value_type, size_t>::value, "size2 type wrong" );
|
static_assert ( std::is_same <size2::value_type, size_t>::value, "size2 type wrong" );
|
||||||
static_assert ( size2::static_size == 2, "size2 size wrong" );
|
static_assert ( size2::static_size == 2, "size2 size wrong" );
|
||||||
|
|
||||||
static_assert ( std::is_same <intmix::value_type, int>::value, "intmix type wrong" );
|
static_assert ( std::is_same <intmix::value_type, int>::value, "intmix type wrong" );
|
||||||
static_assert ( intmix::static_size == 4, "intmix size wrong" );
|
static_assert ( intmix::static_size == 4, "intmix size wrong" );
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ public:
|
|||||||
static_assert ( sizemix::static_size == 5, "sizemix size wrong" );
|
static_assert ( sizemix::static_size == 5, "sizemix size wrong" );
|
||||||
|
|
||||||
auto tup = std::make_tuple ( 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 );
|
auto tup = std::make_tuple ( 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 );
|
||||||
|
|
||||||
// Use them
|
// Use them
|
||||||
auto t3 = extract ( tup, int3() );
|
auto t3 = extract ( tup, int3() );
|
||||||
static_assert ( std::tuple_size<decltype(t3)>::value == int3::static_size, "t3 size wrong");
|
static_assert ( std::tuple_size<decltype(t3)>::value == int3::static_size, "t3 size wrong");
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ template <class T>
|
|||||||
using add_volatile_t = typename add_volatile<T>::type; // C++14
|
using add_volatile_t = typename add_volatile<T>::type; // C++14
|
||||||
template <class T>
|
template <class T>
|
||||||
using add_cv_t = typename add_cv<T>::type; // C++14
|
using add_cv_t = typename add_cv<T>::type; // C++14
|
||||||
|
|
||||||
// reference modifications:
|
// reference modifications:
|
||||||
template <class T>
|
template <class T>
|
||||||
using remove_reference_t = typename remove_reference<T>::type; // C++14
|
using remove_reference_t = typename remove_reference<T>::type; // C++14
|
||||||
@@ -98,13 +98,13 @@ template <class T>
|
|||||||
using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
|
using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
|
||||||
template <class T>
|
template <class T>
|
||||||
using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
|
using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
|
||||||
|
|
||||||
// sign modifications:
|
// sign modifications:
|
||||||
template <class T>
|
template <class T>
|
||||||
using make_signed_t = typename make_signed<T>::type; // C++14
|
using make_signed_t = typename make_signed<T>::type; // C++14
|
||||||
template <class T>
|
template <class T>
|
||||||
using make_unsigned_t = typename make_unsigned<T>::type; // C++14
|
using make_unsigned_t = typename make_unsigned<T>::type; // C++14
|
||||||
|
|
||||||
// array modifications:
|
// array modifications:
|
||||||
template <class T>
|
template <class T>
|
||||||
using remove_extent_t = typename remove_extent<T>::type; // C++14
|
using remove_extent_t = typename remove_extent<T>::type; // C++14
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ struct is_uniquely_represented<T const volatile>
|
|||||||
|
|
||||||
template <class T, class U>
|
template <class T, class U>
|
||||||
struct is_uniquely_represented<std::pair<T, U>>
|
struct is_uniquely_represented<std::pair<T, U>>
|
||||||
: public std::integral_constant<bool, is_uniquely_represented<T>::value &&
|
: public std::integral_constant<bool, is_uniquely_represented<T>::value &&
|
||||||
is_uniquely_represented<U>::value &&
|
is_uniquely_represented<U>::value &&
|
||||||
sizeof(T) + sizeof(U) == sizeof(std::pair<T, U>)>
|
sizeof(T) + sizeof(U) == sizeof(std::pair<T, U>)>
|
||||||
{
|
{
|
||||||
@@ -131,7 +131,7 @@ struct is_uniquely_represented<std::pair<T, U>>
|
|||||||
template <class ...T>
|
template <class ...T>
|
||||||
struct is_uniquely_represented<std::tuple<T...>>
|
struct is_uniquely_represented<std::tuple<T...>>
|
||||||
: public std::integral_constant<bool,
|
: public std::integral_constant<bool,
|
||||||
static_and<is_uniquely_represented<T>::value...>::value &&
|
static_and<is_uniquely_represented<T>::value...>::value &&
|
||||||
static_sum<sizeof(T)...>::value == sizeof(std::tuple<T...>)>
|
static_sum<sizeof(T)...>::value == sizeof(std::tuple<T...>)>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
@@ -148,7 +148,7 @@ struct is_uniquely_represented<T[N]>
|
|||||||
|
|
||||||
template <class T, std::size_t N>
|
template <class T, std::size_t N>
|
||||||
struct is_uniquely_represented<std::array<T, N>>
|
struct is_uniquely_represented<std::array<T, N>>
|
||||||
: public std::integral_constant<bool, is_uniquely_represented<T>::value &&
|
: public std::integral_constant<bool, is_uniquely_represented<T>::value &&
|
||||||
sizeof(T)*N == sizeof(std::array<T, N>)>
|
sizeof(T)*N == sizeof(std::array<T, N>)>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
@@ -159,7 +159,7 @@ struct is_uniquely_represented<std::array<T, N>>
|
|||||||
combination of possible values of `T` held in `x` and `y`,
|
combination of possible values of `T` held in `x` and `y`,
|
||||||
if `x == y`, then it must be true that `memcmp(&x, &y, sizeof(T))`
|
if `x == y`, then it must be true that `memcmp(&x, &y, sizeof(T))`
|
||||||
return 0; i.e. that `x` and `y` are represented by the same bit pattern.
|
return 0; i.e. that `x` and `y` are represented by the same bit pattern.
|
||||||
|
|
||||||
For example: A two's complement `int` should be contiguously hashable.
|
For example: A two's complement `int` should be contiguously hashable.
|
||||||
Every bit pattern produces a unique value that does not compare equal to
|
Every bit pattern produces a unique value that does not compare equal to
|
||||||
any other bit pattern's value. A IEEE floating point should not be
|
any other bit pattern's value. A IEEE floating point should not be
|
||||||
@@ -206,7 +206,7 @@ struct is_contiguously_hashable<T[N], HashAlgorithm>
|
|||||||
Never
|
Never
|
||||||
Effect:
|
Effect:
|
||||||
Returns the reslting hash of all the input data.
|
Returns the reslting hash of all the input data.
|
||||||
*/
|
*/
|
||||||
/** @{ */
|
/** @{ */
|
||||||
|
|
||||||
// scalars
|
// scalars
|
||||||
@@ -271,21 +271,21 @@ hash_append(Hasher& h, T (&a)[N]) noexcept;
|
|||||||
template <class Hasher, class CharT, class Traits, class Alloc>
|
template <class Hasher, class CharT, class Traits, class Alloc>
|
||||||
std::enable_if_t
|
std::enable_if_t
|
||||||
<
|
<
|
||||||
!is_contiguously_hashable<CharT, Hasher>::value
|
!is_contiguously_hashable<CharT, Hasher>::value
|
||||||
>
|
>
|
||||||
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept;
|
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept;
|
||||||
|
|
||||||
template <class Hasher, class CharT, class Traits, class Alloc>
|
template <class Hasher, class CharT, class Traits, class Alloc>
|
||||||
std::enable_if_t
|
std::enable_if_t
|
||||||
<
|
<
|
||||||
is_contiguously_hashable<CharT, Hasher>::value
|
is_contiguously_hashable<CharT, Hasher>::value
|
||||||
>
|
>
|
||||||
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept;
|
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept;
|
||||||
|
|
||||||
template <class Hasher, class T, class U>
|
template <class Hasher, class T, class U>
|
||||||
std::enable_if_t
|
std::enable_if_t
|
||||||
<
|
<
|
||||||
!is_contiguously_hashable<std::pair<T, U>, Hasher>::value
|
!is_contiguously_hashable<std::pair<T, U>, Hasher>::value
|
||||||
>
|
>
|
||||||
hash_append (Hasher& h, std::pair<T, U> const& p) noexcept;
|
hash_append (Hasher& h, std::pair<T, U> const& p) noexcept;
|
||||||
|
|
||||||
@@ -348,7 +348,7 @@ template <class Hasher, class CharT, class Traits, class Alloc>
|
|||||||
inline
|
inline
|
||||||
std::enable_if_t
|
std::enable_if_t
|
||||||
<
|
<
|
||||||
!is_contiguously_hashable<CharT, Hasher>::value
|
!is_contiguously_hashable<CharT, Hasher>::value
|
||||||
>
|
>
|
||||||
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept
|
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept
|
||||||
{
|
{
|
||||||
@@ -361,7 +361,7 @@ template <class Hasher, class CharT, class Traits, class Alloc>
|
|||||||
inline
|
inline
|
||||||
std::enable_if_t
|
std::enable_if_t
|
||||||
<
|
<
|
||||||
is_contiguously_hashable<CharT, Hasher>::value
|
is_contiguously_hashable<CharT, Hasher>::value
|
||||||
>
|
>
|
||||||
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept
|
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,27 +1,27 @@
|
|||||||
//------------------------------- siphash.h ------------------------------------
|
//------------------------------- siphash.h ------------------------------------
|
||||||
//
|
//
|
||||||
// This software is in the public domain. The only restriction on its use is
|
// This software is in the public domain. The only restriction on its use is
|
||||||
// that no one can remove it from the public domain by claiming ownership of it,
|
// that no one can remove it from the public domain by claiming ownership of it,
|
||||||
// including the original authors.
|
// including the original authors.
|
||||||
//
|
//
|
||||||
// There is no warranty of correctness on the software contained herein. Use
|
// There is no warranty of correctness on the software contained herein. Use
|
||||||
// at your own risk.
|
// at your own risk.
|
||||||
//
|
//
|
||||||
// Derived from:
|
// Derived from:
|
||||||
//
|
//
|
||||||
// SipHash reference C implementation
|
// SipHash reference C implementation
|
||||||
//
|
//
|
||||||
// Written in 2012 by Jean-Philippe Aumasson <jeanphilippe.aumasson@gmail.com>
|
// Written in 2012 by Jean-Philippe Aumasson <jeanphilippe.aumasson@gmail.com>
|
||||||
// Daniel J. Bernstein <djb@cr.yp.to>
|
// Daniel J. Bernstein <djb@cr.yp.to>
|
||||||
//
|
//
|
||||||
// To the extent possible under law, the author(s) have dedicated all copyright
|
// To the extent possible under law, the author(s) have dedicated all copyright
|
||||||
// and related and neighboring rights to this software to the public domain
|
// and related and neighboring rights to this software to the public domain
|
||||||
// worldwide. This software is distributed without any warranty.
|
// worldwide. This software is distributed without any warranty.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the CC0 Public Domain Dedication along
|
// You should have received a copy of the CC0 Public Domain Dedication along
|
||||||
// with this software. If not, see
|
// with this software. If not, see
|
||||||
// <http://creativecommons.org/publicdomain/zero/1.0/>.
|
// <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
//
|
//
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include <beast/hash/siphash.h>
|
#include <beast/hash/siphash.h>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#define ALLOW_UNALIGNED_READS 1
|
#define ALLOW_UNALIGNED_READS 1
|
||||||
|
|
||||||
//
|
//
|
||||||
// short hash ... it could be used on any message,
|
// short hash ... it could be used on any message,
|
||||||
// but it's used by Spooky just for short messages.
|
// but it's used by Spooky just for short messages.
|
||||||
//
|
//
|
||||||
void SpookyHash::Short(
|
void SpookyHash::Short(
|
||||||
@@ -31,16 +31,16 @@ void SpookyHash::Short(
|
|||||||
uint64 *hash2)
|
uint64 *hash2)
|
||||||
{
|
{
|
||||||
uint64 buf[2*sc_numVars];
|
uint64 buf[2*sc_numVars];
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
const uint8 *p8;
|
const uint8 *p8;
|
||||||
uint32 *p32;
|
uint32 *p32;
|
||||||
uint64 *p64;
|
uint64 *p64;
|
||||||
size_t i;
|
size_t i;
|
||||||
} u;
|
} u;
|
||||||
|
|
||||||
u.p8 = (const uint8 *)message;
|
u.p8 = (const uint8 *)message;
|
||||||
|
|
||||||
if (!ALLOW_UNALIGNED_READS && (u.i & 0x7))
|
if (!ALLOW_UNALIGNED_READS && (u.i & 0x7))
|
||||||
{
|
{
|
||||||
memcpy(buf, message, length);
|
memcpy(buf, message, length);
|
||||||
@@ -56,7 +56,7 @@ void SpookyHash::Short(
|
|||||||
if (length > 15)
|
if (length > 15)
|
||||||
{
|
{
|
||||||
const uint64 *end = u.p64 + (length/32)*4;
|
const uint64 *end = u.p64 + (length/32)*4;
|
||||||
|
|
||||||
// handle all complete sets of 32 bytes
|
// handle all complete sets of 32 bytes
|
||||||
for (; u.p64 < end; u.p64 += 4)
|
for (; u.p64 < end; u.p64 += 4)
|
||||||
{
|
{
|
||||||
@@ -66,7 +66,7 @@ void SpookyHash::Short(
|
|||||||
a += u.p64[2];
|
a += u.p64[2];
|
||||||
b += u.p64[3];
|
b += u.p64[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
//Handle the case of 16+ remaining bytes.
|
//Handle the case of 16+ remaining bytes.
|
||||||
if (remainder >= 16)
|
if (remainder >= 16)
|
||||||
{
|
{
|
||||||
@@ -77,7 +77,7 @@ void SpookyHash::Short(
|
|||||||
remainder -= 16;
|
remainder -= 16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle the last 0..15 bytes, and its length
|
// Handle the last 0..15 bytes, and its length
|
||||||
d += ((uint64)length) << 56;
|
d += ((uint64)length) << 56;
|
||||||
switch (remainder)
|
switch (remainder)
|
||||||
@@ -131,9 +131,9 @@ void SpookyHash::Short(
|
|||||||
|
|
||||||
// do the whole hash in one call
|
// do the whole hash in one call
|
||||||
void SpookyHash::Hash128(
|
void SpookyHash::Hash128(
|
||||||
const void *message,
|
const void *message,
|
||||||
size_t length,
|
size_t length,
|
||||||
uint64 *hash1,
|
uint64 *hash1,
|
||||||
uint64 *hash2)
|
uint64 *hash2)
|
||||||
{
|
{
|
||||||
if (length < sc_bufSize)
|
if (length < sc_bufSize)
|
||||||
@@ -145,18 +145,18 @@ void SpookyHash::Hash128(
|
|||||||
uint64 h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11;
|
uint64 h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11;
|
||||||
uint64 buf[sc_numVars];
|
uint64 buf[sc_numVars];
|
||||||
uint64 *end;
|
uint64 *end;
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
const uint8 *p8;
|
const uint8 *p8;
|
||||||
uint64 *p64;
|
uint64 *p64;
|
||||||
size_t i;
|
size_t i;
|
||||||
} u;
|
} u;
|
||||||
size_t remainder;
|
size_t remainder;
|
||||||
|
|
||||||
h0=h3=h6=h9 = *hash1;
|
h0=h3=h6=h9 = *hash1;
|
||||||
h1=h4=h7=h10 = *hash2;
|
h1=h4=h7=h10 = *hash2;
|
||||||
h2=h5=h8=h11 = sc_const;
|
h2=h5=h8=h11 = sc_const;
|
||||||
|
|
||||||
u.p8 = (const uint8 *)message;
|
u.p8 = (const uint8 *)message;
|
||||||
end = u.p64 + (length/sc_blockSize)*sc_numVars;
|
end = u.p64 + (length/sc_blockSize)*sc_numVars;
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ void SpookyHash::Hash128(
|
|||||||
if (ALLOW_UNALIGNED_READS || ((u.i & 0x7) == 0))
|
if (ALLOW_UNALIGNED_READS || ((u.i & 0x7) == 0))
|
||||||
{
|
{
|
||||||
while (u.p64 < end)
|
while (u.p64 < end)
|
||||||
{
|
{
|
||||||
Mix(u.p64, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
|
Mix(u.p64, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
|
||||||
u.p64 += sc_numVars;
|
u.p64 += sc_numVars;
|
||||||
}
|
}
|
||||||
@@ -185,8 +185,8 @@ void SpookyHash::Hash128(
|
|||||||
memset(((uint8 *)buf)+remainder, 0, sc_blockSize-remainder);
|
memset(((uint8 *)buf)+remainder, 0, sc_blockSize-remainder);
|
||||||
((uint8 *)buf)[sc_blockSize-1] =
|
((uint8 *)buf)[sc_blockSize-1] =
|
||||||
static_cast<uint8>(remainder);
|
static_cast<uint8>(remainder);
|
||||||
|
|
||||||
// do some final mixing
|
// do some final mixing
|
||||||
End(buf, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
|
End(buf, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
|
||||||
*hash1 = h0;
|
*hash1 = h0;
|
||||||
*hash2 = h1;
|
*hash2 = h1;
|
||||||
@@ -210,14 +210,14 @@ void SpookyHash::Update(const void *message, size_t length)
|
|||||||
uint64 h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11;
|
uint64 h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11;
|
||||||
size_t newLength = length + m_remainder;
|
size_t newLength = length + m_remainder;
|
||||||
uint8 remainder;
|
uint8 remainder;
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
const uint8 *p8;
|
const uint8 *p8;
|
||||||
uint64 *p64;
|
uint64 *p64;
|
||||||
size_t i;
|
size_t i;
|
||||||
} u;
|
} u;
|
||||||
const uint64 *end;
|
const uint64 *end;
|
||||||
|
|
||||||
// Is this message fragment too short? If it is, stuff it away.
|
// Is this message fragment too short? If it is, stuff it away.
|
||||||
if (newLength < sc_bufSize)
|
if (newLength < sc_bufSize)
|
||||||
{
|
{
|
||||||
@@ -226,7 +226,7 @@ void SpookyHash::Update(const void *message, size_t length)
|
|||||||
m_remainder = (uint8)newLength;
|
m_remainder = (uint8)newLength;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// init the variables
|
// init the variables
|
||||||
if (m_length < sc_bufSize)
|
if (m_length < sc_bufSize)
|
||||||
{
|
{
|
||||||
@@ -250,7 +250,7 @@ void SpookyHash::Update(const void *message, size_t length)
|
|||||||
h11 = m_state[11];
|
h11 = m_state[11];
|
||||||
}
|
}
|
||||||
m_length = length + m_length;
|
m_length = length + m_length;
|
||||||
|
|
||||||
// if we've got anything stuffed away, use it now
|
// if we've got anything stuffed away, use it now
|
||||||
if (m_remainder)
|
if (m_remainder)
|
||||||
{
|
{
|
||||||
@@ -266,14 +266,14 @@ void SpookyHash::Update(const void *message, size_t length)
|
|||||||
{
|
{
|
||||||
u.p8 = (const uint8 *)message;
|
u.p8 = (const uint8 *)message;
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle all whole blocks of sc_blockSize bytes
|
// handle all whole blocks of sc_blockSize bytes
|
||||||
end = u.p64 + (length/sc_blockSize)*sc_numVars;
|
end = u.p64 + (length/sc_blockSize)*sc_numVars;
|
||||||
remainder = (uint8)(length-((const uint8 *)end-u.p8));
|
remainder = (uint8)(length-((const uint8 *)end-u.p8));
|
||||||
if (ALLOW_UNALIGNED_READS || (u.i & 0x7) == 0)
|
if (ALLOW_UNALIGNED_READS || (u.i & 0x7) == 0)
|
||||||
{
|
{
|
||||||
while (u.p64 < end)
|
while (u.p64 < end)
|
||||||
{
|
{
|
||||||
Mix(u.p64, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
|
Mix(u.p64, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
|
||||||
u.p64 += sc_numVars;
|
u.p64 += sc_numVars;
|
||||||
}
|
}
|
||||||
@@ -281,7 +281,7 @@ void SpookyHash::Update(const void *message, size_t length)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (u.p64 < end)
|
while (u.p64 < end)
|
||||||
{
|
{
|
||||||
memcpy(m_data, u.p8, sc_blockSize);
|
memcpy(m_data, u.p8, sc_blockSize);
|
||||||
Mix(m_data, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
|
Mix(m_data, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
|
||||||
u.p64 += sc_numVars;
|
u.p64 += sc_numVars;
|
||||||
@@ -291,7 +291,7 @@ void SpookyHash::Update(const void *message, size_t length)
|
|||||||
// stuff away the last few bytes
|
// stuff away the last few bytes
|
||||||
m_remainder = remainder;
|
m_remainder = remainder;
|
||||||
memcpy(m_data, end, remainder);
|
memcpy(m_data, end, remainder);
|
||||||
|
|
||||||
// stuff away the variables
|
// stuff away the variables
|
||||||
m_state[0] = h0;
|
m_state[0] = h0;
|
||||||
m_state[1] = h1;
|
m_state[1] = h1;
|
||||||
@@ -319,10 +319,10 @@ void SpookyHash::Final(uint64 *hash1, uint64 *hash2)
|
|||||||
Short( m_data, m_length, hash1, hash2);
|
Short( m_data, m_length, hash1, hash2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint64 *data = (const uint64 *)m_data;
|
const uint64 *data = (const uint64 *)m_data;
|
||||||
uint8 remainder = m_remainder;
|
uint8 remainder = m_remainder;
|
||||||
|
|
||||||
uint64 h0 = m_state[0];
|
uint64 h0 = m_state[0];
|
||||||
uint64 h1 = m_state[1];
|
uint64 h1 = m_state[1];
|
||||||
uint64 h2 = m_state[2];
|
uint64 h2 = m_state[2];
|
||||||
@@ -348,7 +348,7 @@ void SpookyHash::Final(uint64 *hash1, uint64 *hash2)
|
|||||||
memset(&((uint8 *)data)[remainder], 0, (sc_blockSize-remainder));
|
memset(&((uint8 *)data)[remainder], 0, (sc_blockSize-remainder));
|
||||||
|
|
||||||
((uint8 *)data)[sc_blockSize-1] = remainder;
|
((uint8 *)data)[sc_blockSize-1] = remainder;
|
||||||
|
|
||||||
// do some final mixing
|
// do some final mixing
|
||||||
End(data, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
|
End(data, h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
// Feb 5 2012: adjusted definitions of uint* to be more portable
|
// Feb 5 2012: adjusted definitions of uint* to be more portable
|
||||||
// Mar 30 2012: 3 bytes/cycle, not 4. Alpha was 4 but wasn't thorough enough.
|
// Mar 30 2012: 3 bytes/cycle, not 4. Alpha was 4 but wasn't thorough enough.
|
||||||
// August 5 2012: SpookyV2 (different results)
|
// August 5 2012: SpookyV2 (different results)
|
||||||
//
|
//
|
||||||
// Up to 3 bytes/cycle for long messages. Reasonably fast for short messages.
|
// Up to 3 bytes/cycle for long messages. Reasonably fast for short messages.
|
||||||
// All 1 or 2 bit deltas achieve avalanche within 1% bias per output bit.
|
// All 1 or 2 bit deltas achieve avalanche within 1% bias per output bit.
|
||||||
//
|
//
|
||||||
@@ -20,9 +20,9 @@
|
|||||||
//
|
//
|
||||||
// Google's CityHash has similar specs to SpookyHash, and CityHash is faster
|
// Google's CityHash has similar specs to SpookyHash, and CityHash is faster
|
||||||
// on new Intel boxes. MD4 and MD5 also have similar specs, but they are orders
|
// on new Intel boxes. MD4 and MD5 also have similar specs, but they are orders
|
||||||
// of magnitude slower. CRCs are two or more times slower, but unlike
|
// of magnitude slower. CRCs are two or more times slower, but unlike
|
||||||
// SpookyHash, they have nice math for combining the CRCs of pieces to form
|
// SpookyHash, they have nice math for combining the CRCs of pieces to form
|
||||||
// the CRCs of wholes. There are also cryptographic hashes, but those are even
|
// the CRCs of wholes. There are also cryptographic hashes, but those are even
|
||||||
// slower than MD5.
|
// slower than MD5.
|
||||||
//
|
//
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ public:
|
|||||||
void Init(
|
void Init(
|
||||||
uint64 seed1, // any 64-bit value will do, including 0
|
uint64 seed1, // any 64-bit value will do, including 0
|
||||||
uint64 seed2); // different seeds produce independent hashes
|
uint64 seed2); // different seeds produce independent hashes
|
||||||
|
|
||||||
//
|
//
|
||||||
// Update: add a piece of a message to a SpookyHash state
|
// Update: add a piece of a message to a SpookyHash state
|
||||||
//
|
//
|
||||||
@@ -134,7 +134,7 @@ public:
|
|||||||
// I tried 3 pairs of each; they all differed by at least 212 bits.
|
// I tried 3 pairs of each; they all differed by at least 212 bits.
|
||||||
//
|
//
|
||||||
static INLINE void Mix(
|
static INLINE void Mix(
|
||||||
const uint64 *data,
|
const uint64 *data,
|
||||||
uint64 &s0, uint64 &s1, uint64 &s2, uint64 &s3,
|
uint64 &s0, uint64 &s1, uint64 &s2, uint64 &s3,
|
||||||
uint64 &s4, uint64 &s5, uint64 &s6, uint64 &s7,
|
uint64 &s4, uint64 &s5, uint64 &s6, uint64 &s7,
|
||||||
uint64 &s8, uint64 &s9, uint64 &s10,uint64 &s11)
|
uint64 &s8, uint64 &s9, uint64 &s10,uint64 &s11)
|
||||||
@@ -171,7 +171,7 @@ public:
|
|||||||
//
|
//
|
||||||
static INLINE void EndPartial(
|
static INLINE void EndPartial(
|
||||||
uint64 &h0, uint64 &h1, uint64 &h2, uint64 &h3,
|
uint64 &h0, uint64 &h1, uint64 &h2, uint64 &h3,
|
||||||
uint64 &h4, uint64 &h5, uint64 &h6, uint64 &h7,
|
uint64 &h4, uint64 &h5, uint64 &h6, uint64 &h7,
|
||||||
uint64 &h8, uint64 &h9, uint64 &h10,uint64 &h11)
|
uint64 &h8, uint64 &h9, uint64 &h10,uint64 &h11)
|
||||||
{
|
{
|
||||||
h11+= h1; h2 ^= h11; h1 = Rot64(h1,44);
|
h11+= h1; h2 ^= h11; h1 = Rot64(h1,44);
|
||||||
@@ -189,9 +189,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static INLINE void End(
|
static INLINE void End(
|
||||||
const uint64 *data,
|
const uint64 *data,
|
||||||
uint64 &h0, uint64 &h1, uint64 &h2, uint64 &h3,
|
uint64 &h0, uint64 &h1, uint64 &h2, uint64 &h3,
|
||||||
uint64 &h4, uint64 &h5, uint64 &h6, uint64 &h7,
|
uint64 &h4, uint64 &h5, uint64 &h6, uint64 &h7,
|
||||||
uint64 &h8, uint64 &h9, uint64 &h10,uint64 &h11)
|
uint64 &h8, uint64 &h9, uint64 &h10,uint64 &h11)
|
||||||
{
|
{
|
||||||
h0 += data[0]; h1 += data[1]; h2 += data[2]; h3 += data[3];
|
h0 += data[0]; h1 += data[1]; h2 += data[2]; h3 += data[3];
|
||||||
@@ -203,7 +203,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// The goal is for each bit of the input to expand into 128 bits of
|
// The goal is for each bit of the input to expand into 128 bits of
|
||||||
// apparent entropy before it is fully overwritten.
|
// apparent entropy before it is fully overwritten.
|
||||||
// n trials both set and cleared at least m bits of h0 h1 h2 h3
|
// n trials both set and cleared at least m bits of h0 h1 h2 h3
|
||||||
// n: 2 m: 29
|
// n: 2 m: 29
|
||||||
@@ -259,7 +259,7 @@ public:
|
|||||||
h0 ^= h3; h3 = Rot64(h3,25); h0 += h3;
|
h0 ^= h3; h3 = Rot64(h3,25); h0 += h3;
|
||||||
h1 ^= h0; h0 = Rot64(h0,63); h1 += h0;
|
h1 ^= h0; h0 = Rot64(h0,63); h1 += h0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -267,7 +267,7 @@ private:
|
|||||||
// Short has a low startup cost, the normal mode is good for long
|
// Short has a low startup cost, the normal mode is good for long
|
||||||
// keys, the cost crossover is at about 192 bytes. The two modes were
|
// keys, the cost crossover is at about 192 bytes. The two modes were
|
||||||
// held to the same quality bar.
|
// held to the same quality bar.
|
||||||
//
|
//
|
||||||
static void Short(
|
static void Short(
|
||||||
const void *message, // message (array of bytes, not necessarily aligned)
|
const void *message, // message (array of bytes, not necessarily aligned)
|
||||||
size_t length, // length of message (in bytes)
|
size_t length, // length of message (in bytes)
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ class spooky
|
|||||||
private:
|
private:
|
||||||
SpookyHash state_;
|
SpookyHash state_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static beast::endian const endian = beast::endian::native;
|
static beast::endian const endian = beast::endian::native;
|
||||||
|
|
||||||
spooky(std::size_t seed1 = 1, std::size_t seed2 = 2) noexcept
|
spooky(std::size_t seed1 = 1, std::size_t seed2 = 2) noexcept
|
||||||
@@ -429,9 +429,9 @@ public:
|
|||||||
{
|
{
|
||||||
auto const start (
|
auto const start (
|
||||||
std::chrono::high_resolution_clock::now());
|
std::chrono::high_resolution_clock::now());
|
||||||
|
|
||||||
auto const hashes (make_hashes <Hasher> (keys));
|
auto const hashes (make_hashes <Hasher> (keys));
|
||||||
|
|
||||||
results.elapsed = std::chrono::duration_cast <std::chrono::milliseconds> (
|
results.elapsed = std::chrono::duration_cast <std::chrono::milliseconds> (
|
||||||
std::chrono::high_resolution_clock::now() - start);
|
std::chrono::high_resolution_clock::now() - start);
|
||||||
|
|
||||||
|
|||||||
@@ -396,4 +396,4 @@ build_map (headers const& h)
|
|||||||
} // http
|
} // http
|
||||||
} // beast
|
} // beast
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ to_string (URL const& url)
|
|||||||
|
|
||||||
s.append (url.scheme ());
|
s.append (url.scheme ());
|
||||||
s.append ("://");
|
s.append ("://");
|
||||||
|
|
||||||
if (!url.userinfo ().empty ())
|
if (!url.userinfo ().empty ())
|
||||||
{
|
{
|
||||||
s.append (url.userinfo ());
|
s.append (url.userinfo ());
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ basic_parser::basic_parser (bool request) noexcept
|
|||||||
h->on_headers_complete = &basic_parser::cb_headers_complete;
|
h->on_headers_complete = &basic_parser::cb_headers_complete;
|
||||||
h->on_body = &basic_parser::cb_body;
|
h->on_body = &basic_parser::cb_body;
|
||||||
h->on_message_complete = &basic_parser::cb_message_complete;
|
h->on_message_complete = &basic_parser::cb_message_complete;
|
||||||
|
|
||||||
joyent::http_parser_init (s, request
|
joyent::http_parser_init (s, request
|
||||||
? joyent::http_parser_type::HTTP_REQUEST
|
? joyent::http_parser_type::HTTP_REQUEST
|
||||||
: joyent::http_parser_type::HTTP_RESPONSE);
|
: joyent::http_parser_type::HTTP_RESPONSE);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ basic_url_base::parse_impl (string_ref s, boost::system::error_code& ec)
|
|||||||
joyent::http_parser_url p;
|
joyent::http_parser_url p;
|
||||||
|
|
||||||
value_type const* const data (s.data());
|
value_type const* const data (s.data());
|
||||||
|
|
||||||
int const error (joyent::http_parser_parse_url (
|
int const error (joyent::http_parser_parse_url (
|
||||||
data, s.size(), false, &p));
|
data, s.size(), false, &p));
|
||||||
|
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ convert_http_errno (joyent::http_errno err)
|
|||||||
{
|
{
|
||||||
return default_error_condition (code) == condition;
|
return default_error_condition (code) == condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
equivalent (error_code const& code, int condition
|
equivalent (error_code const& code, int condition
|
||||||
) const noexcept override
|
) const noexcept override
|
||||||
@@ -151,7 +151,7 @@ convert_http_errno (joyent::http_errno err)
|
|||||||
};
|
};
|
||||||
|
|
||||||
static http_error_category_t http_error_category;
|
static http_error_category_t http_error_category;
|
||||||
|
|
||||||
return boost::system::error_code (
|
return boost::system::error_code (
|
||||||
err, http_error_category);
|
err, http_error_category);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
// TODO Use <system_error>
|
// TODO Use <system_error>
|
||||||
#include <boost/system/error_code.hpp>
|
#include <boost/system/error_code.hpp>
|
||||||
|
|
||||||
// Wraps the C-language joyent http parser header in a namespace
|
// Wraps the C-language joyent http parser header in a namespace
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace joyent {
|
namespace joyent {
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ private:
|
|||||||
// request
|
// request
|
||||||
beast::http::method_t method_;
|
beast::http::method_t method_;
|
||||||
std::string url_;
|
std::string url_;
|
||||||
|
|
||||||
// response
|
// response
|
||||||
int status_;
|
int status_;
|
||||||
std::string reason_;
|
std::string reason_;
|
||||||
@@ -248,7 +248,7 @@ message::operator= (message&& other)
|
|||||||
keep_alive_ = other.keep_alive_;
|
keep_alive_ = other.keep_alive_;
|
||||||
upgrade_ = other.upgrade_;
|
upgrade_ = other.upgrade_;
|
||||||
headers = std::move(other.headers);
|
headers = std::move(other.headers);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
message& m, bool request)
|
message& m, bool request)
|
||||||
: beast::http::basic_parser (request)
|
: beast::http::basic_parser (request)
|
||||||
, message_(m)
|
, message_(m)
|
||||||
, write_body_(std::move(write_body))
|
, write_body_(std::move(write_body))
|
||||||
{
|
{
|
||||||
message_.get().request(request);
|
message_.get().request(request);
|
||||||
}
|
}
|
||||||
@@ -208,4 +208,4 @@ parser::do_complete()
|
|||||||
} // http
|
} // http
|
||||||
} // beast
|
} // beast
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public:
|
|||||||
|
|
||||||
void test_url_parsing ()
|
void test_url_parsing ()
|
||||||
{
|
{
|
||||||
char const* const urls[] =
|
char const* const urls[] =
|
||||||
{
|
{
|
||||||
"http://en.wikipedia.org/wiki/URI#Examples_of_URI_references",
|
"http://en.wikipedia.org/wiki/URI#Examples_of_URI_references",
|
||||||
"ftp://ftp.funet.fi/pub/standards/RFC/rfc959.txt"
|
"ftp://ftp.funet.fi/pub/standards/RFC/rfc959.txt"
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public:
|
|||||||
log << encode (std::string(
|
log << encode (std::string(
|
||||||
boost::asio::buffer_cast<char const*>(buf),
|
boost::asio::buffer_cast<char const*>(buf),
|
||||||
boost::asio::buffer_size(buf)));
|
boost::asio::buffer_size(buf)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert a ConstBufferSequence to a string
|
// Convert a ConstBufferSequence to a string
|
||||||
template <class ConstBufferSequence>
|
template <class ConstBufferSequence>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
#include <beast/http/tests/urls_large_data.h>
|
#include <beast/http/tests/urls_large_data.h>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace http {
|
namespace http {
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
virtual ~Collector() = 0;
|
virtual ~Collector() = 0;
|
||||||
|
|
||||||
/** Create a hook.
|
/** Create a hook.
|
||||||
|
|
||||||
A hook is called at each collection interval, on an implementation
|
A hook is called at each collection interval, on an implementation
|
||||||
defined thread. This is a convenience facility for gathering metrics
|
defined thread. This is a convenience facility for gathering metrics
|
||||||
in the polling style. The typical usage is to update all the metrics
|
in the polling style. The typical usage is to update all the metrics
|
||||||
@@ -75,7 +75,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
/** @{ */
|
/** @{ */
|
||||||
virtual Counter make_counter (std::string const& name) = 0;
|
virtual Counter make_counter (std::string const& name) = 0;
|
||||||
|
|
||||||
Counter make_counter (std::string const& prefix, std::string const& name)
|
Counter make_counter (std::string const& prefix, std::string const& name)
|
||||||
{
|
{
|
||||||
if (prefix.empty ())
|
if (prefix.empty ())
|
||||||
@@ -98,7 +98,7 @@ public:
|
|||||||
}
|
}
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/** Create a gauge with the specified name.
|
/** Create a gauge with the specified name.
|
||||||
@see Gauge
|
@see Gauge
|
||||||
*/
|
*/
|
||||||
/** @{ */
|
/** @{ */
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace beast {
|
|||||||
namespace insight {
|
namespace insight {
|
||||||
|
|
||||||
/** A metric for measuring an integral value.
|
/** A metric for measuring an integral value.
|
||||||
|
|
||||||
A counter is a gauge calculated at the server. The owner of the counter
|
A counter is a gauge calculated at the server. The owner of the counter
|
||||||
may increment and decrement the value by an amount.
|
may increment and decrement the value by an amount.
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class CounterImpl
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using value_type = std::int64_t;
|
using value_type = std::int64_t;
|
||||||
|
|
||||||
virtual ~CounterImpl () = 0;
|
virtual ~CounterImpl () = 0;
|
||||||
virtual void increment (value_type amount) = 0;
|
virtual void increment (value_type amount) = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace beast {
|
|||||||
namespace insight {
|
namespace insight {
|
||||||
|
|
||||||
/** A metric for reporting event timing.
|
/** A metric for reporting event timing.
|
||||||
|
|
||||||
An event is an operation that has an associated millisecond time, or
|
An event is an operation that has an associated millisecond time, or
|
||||||
other integral value. Because events happen at a specific moment, the
|
other integral value. Because events happen at a specific moment, the
|
||||||
metric only supports a push-style interface.
|
metric only supports a push-style interface.
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace beast {
|
|||||||
namespace insight {
|
namespace insight {
|
||||||
|
|
||||||
/** A metric for measuring an integral value.
|
/** A metric for measuring an integral value.
|
||||||
|
|
||||||
A gauge is an instantaneous measurement of a value, like the gas gauge
|
A gauge is an instantaneous measurement of a value, like the gas gauge
|
||||||
in a car. The caller directly sets the value, or adjusts it by a
|
in a car. The caller directly sets the value, or adjusts it by a
|
||||||
specified amount. The value is kept in the client rather than the collector.
|
specified amount. The value is kept in the client rather than the collector.
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace insight {
|
namespace insight {
|
||||||
|
|
||||||
/** A reference to a handler for performing polled collection. */
|
/** A reference to a handler for performing polled collection. */
|
||||||
class Hook : public Base
|
class Hook : public Base
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace beast {
|
|||||||
namespace insight {
|
namespace insight {
|
||||||
|
|
||||||
/** A metric for measuring an integral value.
|
/** A metric for measuring an integral value.
|
||||||
|
|
||||||
A meter may be thought of as an increment-only counter.
|
A meter may be thought of as an increment-only counter.
|
||||||
|
|
||||||
This is a lightweight reference wrapper which is cheap to copy and assign.
|
This is a lightweight reference wrapper which is cheap to copy and assign.
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace insight {
|
namespace insight {
|
||||||
|
|
||||||
/** A Collector which does not collect metrics. */
|
/** A Collector which does not collect metrics. */
|
||||||
class NullCollector : public Collector
|
class NullCollector : public Collector
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public:
|
|||||||
{
|
{
|
||||||
return Gauge (std::make_shared <detail::NullGaugeImpl> ());
|
return Gauge (std::make_shared <detail::NullGaugeImpl> ());
|
||||||
}
|
}
|
||||||
|
|
||||||
Meter make_meter (std::string const&)
|
Meter make_meter (std::string const&)
|
||||||
{
|
{
|
||||||
return Meter (std::make_shared <detail::NullMeterImpl> ());
|
return Meter (std::make_shared <detail::NullMeterImpl> ());
|
||||||
|
|||||||
@@ -616,7 +616,7 @@ void StatsDGaugeImpl::flush ()
|
|||||||
void StatsDGaugeImpl::do_set (GaugeImpl::value_type value)
|
void StatsDGaugeImpl::do_set (GaugeImpl::value_type value)
|
||||||
{
|
{
|
||||||
m_value = value;
|
m_value = value;
|
||||||
|
|
||||||
if (m_value != m_last_value)
|
if (m_value != m_last_value)
|
||||||
{
|
{
|
||||||
m_last_value = m_value;
|
m_last_value = m_value;
|
||||||
@@ -641,7 +641,7 @@ void StatsDGaugeImpl::do_increment (GaugeImpl::difference_type amount)
|
|||||||
{
|
{
|
||||||
GaugeImpl::value_type const d (
|
GaugeImpl::value_type const d (
|
||||||
static_cast <GaugeImpl::value_type> (-amount));
|
static_cast <GaugeImpl::value_type> (-amount));
|
||||||
value = (d >= value) ? 0 : value - d;
|
value = (d >= value) ? 0 : value - d;
|
||||||
}
|
}
|
||||||
|
|
||||||
do_set (value);
|
do_set (value);
|
||||||
|
|||||||
@@ -160,91 +160,91 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Intrusive doubly linked list.
|
/** Intrusive doubly linked list.
|
||||||
|
|
||||||
This intrusive List is a container similar in operation to std::list in the
|
This intrusive List is a container similar in operation to std::list in the
|
||||||
Standard Template Library (STL). Like all @ref intrusive containers, List
|
Standard Template Library (STL). Like all @ref intrusive containers, List
|
||||||
requires you to first derive your class from List<>::Node:
|
requires you to first derive your class from List<>::Node:
|
||||||
|
|
||||||
@code
|
@code
|
||||||
|
|
||||||
struct Object : List <Object>::Node
|
struct Object : List <Object>::Node
|
||||||
{
|
{
|
||||||
explicit Object (int value) : m_value (value)
|
explicit Object (int value) : m_value (value)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int m_value;
|
int m_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
Now we define the list, and add a couple of items.
|
Now we define the list, and add a couple of items.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
|
|
||||||
List <Object> list;
|
List <Object> list;
|
||||||
|
|
||||||
list.push_back (* (new Object (1)));
|
list.push_back (* (new Object (1)));
|
||||||
list.push_back (* (new Object (2)));
|
list.push_back (* (new Object (2)));
|
||||||
|
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
For compatibility with the standard containers, push_back() expects a
|
For compatibility with the standard containers, push_back() expects a
|
||||||
reference to the object. Unlike the standard container, however, push_back()
|
reference to the object. Unlike the standard container, however, push_back()
|
||||||
places the actual object in the list and not a copy-constructed duplicate.
|
places the actual object in the list and not a copy-constructed duplicate.
|
||||||
|
|
||||||
Iterating over the list follows the same idiom as the STL:
|
Iterating over the list follows the same idiom as the STL:
|
||||||
|
|
||||||
@code
|
@code
|
||||||
|
|
||||||
for (List <Object>::iterator iter = list.begin(); iter != list.end; ++iter)
|
for (List <Object>::iterator iter = list.begin(); iter != list.end; ++iter)
|
||||||
std::cout << iter->m_value;
|
std::cout << iter->m_value;
|
||||||
|
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
You can even use BOOST_FOREACH, or range based for loops:
|
You can even use BOOST_FOREACH, or range based for loops:
|
||||||
|
|
||||||
@code
|
@code
|
||||||
|
|
||||||
BOOST_FOREACH (Object& object, list) // boost only
|
BOOST_FOREACH (Object& object, list) // boost only
|
||||||
std::cout << object.m_value;
|
std::cout << object.m_value;
|
||||||
|
|
||||||
for (Object& object : list) // C++11 only
|
for (Object& object : list) // C++11 only
|
||||||
std::cout << object.m_value;
|
std::cout << object.m_value;
|
||||||
|
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
Because List is mostly STL compliant, it can be passed into STL algorithms:
|
Because List is mostly STL compliant, it can be passed into STL algorithms:
|
||||||
e.g. `std::for_each()` or `std::find_first_of()`.
|
e.g. `std::for_each()` or `std::find_first_of()`.
|
||||||
|
|
||||||
In general, objects placed into a List should be dynamically allocated
|
In general, objects placed into a List should be dynamically allocated
|
||||||
although this cannot be enforced at compile time. Since the caller provides
|
although this cannot be enforced at compile time. Since the caller provides
|
||||||
the storage for the object, the caller is also responsible for deleting the
|
the storage for the object, the caller is also responsible for deleting the
|
||||||
object. An object still exists after being removed from a List, until the
|
object. An object still exists after being removed from a List, until the
|
||||||
caller deletes it. This means an element can be moved from one List to
|
caller deletes it. This means an element can be moved from one List to
|
||||||
another with practically no overhead.
|
another with practically no overhead.
|
||||||
|
|
||||||
Unlike the standard containers, an object may only exist in one list at a
|
Unlike the standard containers, an object may only exist in one list at a
|
||||||
time, unless special preparations are made. The Tag template parameter is
|
time, unless special preparations are made. The Tag template parameter is
|
||||||
used to distinguish between different list types for the same object,
|
used to distinguish between different list types for the same object,
|
||||||
allowing the object to exist in more than one list simultaneously.
|
allowing the object to exist in more than one list simultaneously.
|
||||||
|
|
||||||
For example, consider an actor system where a global list of actors is
|
For example, consider an actor system where a global list of actors is
|
||||||
maintained, so that they can each be periodically receive processing
|
maintained, so that they can each be periodically receive processing
|
||||||
time. We wish to also maintain a list of the subset of actors that require
|
time. We wish to also maintain a list of the subset of actors that require
|
||||||
a domain-dependent update. To achieve this, we declare two tags, the
|
a domain-dependent update. To achieve this, we declare two tags, the
|
||||||
associated list types, and the list element thusly:
|
associated list types, and the list element thusly:
|
||||||
|
|
||||||
@code
|
@code
|
||||||
|
|
||||||
struct Actor; // Forward declaration required
|
struct Actor; // Forward declaration required
|
||||||
|
|
||||||
struct ProcessTag { };
|
struct ProcessTag { };
|
||||||
struct UpdateTag { };
|
struct UpdateTag { };
|
||||||
|
|
||||||
using ProcessList = List <Actor, ProcessTag>;
|
using ProcessList = List <Actor, ProcessTag>;
|
||||||
using UpdateList = List <Actor, UpdateTag>;
|
using UpdateList = List <Actor, UpdateTag>;
|
||||||
|
|
||||||
// Derive from both node types so we can be in each list at once.
|
// Derive from both node types so we can be in each list at once.
|
||||||
//
|
//
|
||||||
struct Actor : ProcessList::Node, UpdateList::Node
|
struct Actor : ProcessList::Node, UpdateList::Node
|
||||||
@@ -252,15 +252,15 @@ private:
|
|||||||
bool process (); // returns true if we need an update
|
bool process (); // returns true if we need an update
|
||||||
void update ();
|
void update ();
|
||||||
};
|
};
|
||||||
|
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
@tparam T The base type of element which the list will store
|
@tparam T The base type of element which the list will store
|
||||||
pointers to.
|
pointers to.
|
||||||
|
|
||||||
@tparam Tag An optional unique type name used to distinguish lists and nodes,
|
@tparam Tag An optional unique type name used to distinguish lists and nodes,
|
||||||
when the object can exist in multiple lists simultaneously.
|
when the object can exist in multiple lists simultaneously.
|
||||||
|
|
||||||
@ingroup beast_core intrusive
|
@ingroup beast_core intrusive
|
||||||
*/
|
*/
|
||||||
template <typename T, typename Tag = void>
|
template <typename T, typename Tag = void>
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public:
|
|||||||
class Node
|
class Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Node ()
|
Node ()
|
||||||
: m_next (nullptr)
|
: m_next (nullptr)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@@ -159,7 +159,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class LockFreeStack;
|
friend class LockFreeStack;
|
||||||
|
|
||||||
template <class Container, bool IsConst>
|
template <class Container, bool IsConst>
|
||||||
friend class LockFreeStackIterator;
|
friend class LockFreeStackIterator;
|
||||||
|
|
||||||
@@ -262,7 +262,7 @@ public:
|
|||||||
{
|
{
|
||||||
return iterator (&m_end);
|
return iterator (&m_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator begin () const
|
const_iterator begin () const
|
||||||
{
|
{
|
||||||
return const_iterator (m_head.load ());
|
return const_iterator (m_head.load ());
|
||||||
@@ -272,7 +272,7 @@ public:
|
|||||||
{
|
{
|
||||||
return const_iterator (&m_end);
|
return const_iterator (&m_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator cbegin () const
|
const_iterator cbegin () const
|
||||||
{
|
{
|
||||||
return const_iterator (m_head.load ());
|
return const_iterator (m_head.load ());
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public:
|
|||||||
|
|
||||||
/** Outputs all the HTTPMessage data excluding the body into a string. */
|
/** Outputs all the HTTPMessage data excluding the body into a string. */
|
||||||
String toString () const;
|
String toString () const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HTTPVersion m_version;
|
HTTPVersion m_version;
|
||||||
HTTPHeaders m_headers;
|
HTTPHeaders m_headers;
|
||||||
|
|||||||
@@ -727,7 +727,7 @@ public:
|
|||||||
|
|
||||||
if (isPositiveAndBelow (indexToRemove, numUsed))
|
if (isPositiveAndBelow (indexToRemove, numUsed))
|
||||||
{
|
{
|
||||||
bassert (data.elements != nullptr);
|
bassert (data.elements != nullptr);
|
||||||
ElementType removed (data.elements[indexToRemove]);
|
ElementType removed (data.elements[indexToRemove]);
|
||||||
removeInternal (indexToRemove);
|
removeInternal (indexToRemove);
|
||||||
return removed;
|
return removed;
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ bool chopUInt (int& value, int limit, std::string& input)
|
|||||||
auto left_iter = std::find_if_not (input.begin (), input.end (),
|
auto left_iter = std::find_if_not (input.begin (), input.end (),
|
||||||
[](std::string::value_type c)
|
[](std::string::value_type c)
|
||||||
{
|
{
|
||||||
return std::isdigit (c, std::locale::classic());
|
return std::isdigit (c, std::locale::classic());
|
||||||
});
|
});
|
||||||
|
|
||||||
std::string item (input.begin (), left_iter);
|
std::string item (input.begin (), left_iter);
|
||||||
@@ -163,7 +163,7 @@ bool SemanticVersion::parse (std::string const& input, bool debug)
|
|||||||
auto left_iter = std::find_if_not (input.begin (), input.end (),
|
auto left_iter = std::find_if_not (input.begin (), input.end (),
|
||||||
[](std::string::value_type c)
|
[](std::string::value_type c)
|
||||||
{
|
{
|
||||||
return std::isspace (c, std::locale::classic());
|
return std::isspace (c, std::locale::classic());
|
||||||
});
|
});
|
||||||
|
|
||||||
auto right_iter = std::find_if_not (input.rbegin (), input.rend (),
|
auto right_iter = std::find_if_not (input.rbegin (), input.rend (),
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public:
|
|||||||
std::string print () const;
|
std::string print () const;
|
||||||
|
|
||||||
inline bool isRelease () const noexcept
|
inline bool isRelease () const noexcept
|
||||||
{
|
{
|
||||||
return preReleaseIdentifiers.empty();
|
return preReleaseIdentifiers.empty();
|
||||||
}
|
}
|
||||||
inline bool isPreRelease () const noexcept
|
inline bool isPreRelease () const noexcept
|
||||||
@@ -75,8 +75,8 @@ public:
|
|||||||
int compare (SemanticVersion const& lhs, SemanticVersion const& rhs);
|
int compare (SemanticVersion const& lhs, SemanticVersion const& rhs);
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
operator== (SemanticVersion const& lhs, SemanticVersion const& rhs)
|
operator== (SemanticVersion const& lhs, SemanticVersion const& rhs)
|
||||||
{
|
{
|
||||||
return compare (lhs, rhs) == 0;
|
return compare (lhs, rhs) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,4 +109,4 @@ private:
|
|||||||
|
|
||||||
} // beast
|
} // beast
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public:
|
|||||||
|
|
||||||
/** Reads a boolean from the stream.
|
/** Reads a boolean from the stream.
|
||||||
|
|
||||||
The bool is encoded as a single byte - non-zero for true, 0 for false.
|
The bool is encoded as a single byte - non-zero for true, 0 for false.
|
||||||
|
|
||||||
If the stream is exhausted, this will return false.
|
If the stream is exhausted, this will return false.
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ public:
|
|||||||
|
|
||||||
/** Reads two bytes from the stream as a little-endian 16-bit value.
|
/** Reads two bytes from the stream as a little-endian 16-bit value.
|
||||||
|
|
||||||
If the next two bytes read are byte1 and byte2, this returns (byte1 | (byte2 << 8)).
|
If the next two bytes read are byte1 and byte2, this returns (byte1 | (byte2 << 8)).
|
||||||
|
|
||||||
If the stream is exhausted partway through reading the bytes, this will return zero.
|
If the stream is exhausted partway through reading the bytes, this will return zero.
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace beast
|
|||||||
*/
|
*/
|
||||||
class MemoryOutputStream
|
class MemoryOutputStream
|
||||||
: public OutputStream
|
: public OutputStream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
/** Creates an empty memory stream, ready to be written into.
|
/** Creates an empty memory stream, ready to be written into.
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ parse_negative_integral (Int& num, FwdIt first, FwdIt last)
|
|||||||
if (limit_digit < 0)
|
if (limit_digit < 0)
|
||||||
limit_digit = -limit_digit;
|
limit_digit = -limit_digit;
|
||||||
|
|
||||||
return parse_integral<Int> (num, first, last,
|
return parse_integral<Int> (num, first, last,
|
||||||
[limit_value, limit_digit](Int& value, Int digit)
|
[limit_value, limit_digit](Int& value, Int digit)
|
||||||
{
|
{
|
||||||
assert ((digit >= 0) && (digit <= 9));
|
assert ((digit >= 0) && (digit <= 9));
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
|
|
||||||
DeadlineTimer (DeadlineTimer const&) = delete;
|
DeadlineTimer (DeadlineTimer const&) = delete;
|
||||||
DeadlineTimer& operator= (DeadlineTimer const&) = delete;
|
DeadlineTimer& operator= (DeadlineTimer const&) = delete;
|
||||||
|
|
||||||
~DeadlineTimer ();
|
~DeadlineTimer ();
|
||||||
|
|
||||||
/** Cancel all notifications.
|
/** Cancel all notifications.
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ void Workers::deleteWorkers (LockFreeStack <Worker>& stack)
|
|||||||
|
|
||||||
if (worker != nullptr)
|
if (worker != nullptr)
|
||||||
{
|
{
|
||||||
// This call blocks until the thread orderly exits
|
// This call blocks until the thread orderly exits
|
||||||
delete worker;
|
delete worker;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (m_lock_count > 0)
|
if (m_lock_count > 0)
|
||||||
unlock ();
|
unlock ();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void lock (char const* fileName, int lineNumber) noexcept
|
inline void lock (char const* fileName, int lineNumber) noexcept
|
||||||
{
|
{
|
||||||
@@ -233,7 +233,7 @@ public:
|
|||||||
m_mutex.unlock ();
|
m_mutex.unlock ();
|
||||||
--m_lock_count;
|
--m_lock_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Mutex const& m_mutex;
|
Mutex const& m_mutex;
|
||||||
int m_lock_count;
|
int m_lock_count;
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
inline explicit GenericScopedUnlock (LockType& lock) noexcept
|
inline explicit GenericScopedUnlock (LockType& lock) noexcept
|
||||||
: lock_ (lock)
|
: lock_ (lock)
|
||||||
{
|
{
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public:
|
|||||||
|
|
||||||
/** Create the dynamic buffer with the specified block size. */
|
/** Create the dynamic buffer with the specified block size. */
|
||||||
explicit DynamicBuffer (size_type blocksize = defaultBlocksize);
|
explicit DynamicBuffer (size_type blocksize = defaultBlocksize);
|
||||||
|
|
||||||
DynamicBuffer (DynamicBuffer const& other);
|
DynamicBuffer (DynamicBuffer const& other);
|
||||||
|
|
||||||
~DynamicBuffer ();
|
~DynamicBuffer ();
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public:
|
|||||||
return is_v4 () ? m_v4 == IP::AddressV4::any ()
|
return is_v4 () ? m_v4 == IP::AddressV4::any ()
|
||||||
: false; // m_v6 == IP::AddressV6::any();
|
: false; // m_v6 == IP::AddressV6::any();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Hasher>
|
template <class Hasher>
|
||||||
friend
|
friend
|
||||||
void
|
void
|
||||||
@@ -198,21 +198,21 @@ public:
|
|||||||
{
|
{
|
||||||
return ! (lhs == rhs);
|
return ! (lhs == rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
bool
|
bool
|
||||||
operator> (Address const& lhs, Address const& rhs)
|
operator> (Address const& lhs, Address const& rhs)
|
||||||
{
|
{
|
||||||
return rhs < lhs;
|
return rhs < lhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
bool
|
bool
|
||||||
operator<= (Address const& lhs, Address const& rhs)
|
operator<= (Address const& lhs, Address const& rhs)
|
||||||
{
|
{
|
||||||
return ! (lhs > rhs);
|
return ! (lhs > rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
bool
|
bool
|
||||||
operator>= (Address const& lhs, Address const& rhs)
|
operator>= (Address const& lhs, Address const& rhs)
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ struct AddressV4
|
|||||||
AddressV4 ();
|
AddressV4 ();
|
||||||
|
|
||||||
/** Construct from a 32-bit unsigned.
|
/** Construct from a 32-bit unsigned.
|
||||||
@note Octets are formed in order from the MSB to the LSB.
|
@note Octets are formed in order from the MSB to the LSB.
|
||||||
*/
|
*/
|
||||||
explicit AddressV4 (std::uint32_t value_);
|
explicit AddressV4 (std::uint32_t value_);
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ void DynamicBuffer::shrink_to_fit ()
|
|||||||
{
|
{
|
||||||
free (m_buffers.back ());
|
free (m_buffers.back ());
|
||||||
m_buffers.erase (m_buffers.end () - 1);
|
m_buffers.erase (m_buffers.end () - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DynamicBuffer::to_string () const
|
std::string DynamicBuffer::to_string () const
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace IP {
|
namespace IP {
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ struct api
|
|||||||
dat_path, key_path, log_path,
|
dat_path, key_path, log_path,
|
||||||
appnum, salt, key_size, block_size,
|
appnum, salt, key_size, block_size,
|
||||||
load_factor, args...);
|
load_factor, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... Args>
|
template <class... Args>
|
||||||
static
|
static
|
||||||
@@ -91,7 +91,7 @@ struct api
|
|||||||
return nudb::verify<Hasher>(
|
return nudb::verify<Hasher>(
|
||||||
dat_path, key_path, BufferSize);
|
dat_path, key_path, BufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Function>
|
template <class Function>
|
||||||
static
|
static
|
||||||
bool
|
bool
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ struct varint;
|
|||||||
// possible size of T represented as varint.
|
// possible size of T represented as varint.
|
||||||
// T must be unsigned
|
// T must be unsigned
|
||||||
template <class T,
|
template <class T,
|
||||||
bool = std::is_unsigned<T>::value>
|
bool = std::is_unsigned<T>::value>
|
||||||
struct varint_traits;
|
struct varint_traits;
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace nudb {
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
TODO
|
TODO
|
||||||
|
|
||||||
- fingerprint / checksum on log records
|
- fingerprint / checksum on log records
|
||||||
|
|
||||||
- size field at end of data records
|
- size field at end of data records
|
||||||
@@ -550,7 +550,7 @@ store<Hasher, Codec, File>::fetch (
|
|||||||
if (item.hash != h)
|
if (item.hash != h)
|
||||||
break;
|
break;
|
||||||
// Data Record
|
// Data Record
|
||||||
auto const len =
|
auto const len =
|
||||||
s_->kh.key_size + // Key
|
s_->kh.key_size + // Key
|
||||||
item.size; // Value
|
item.size; // Value
|
||||||
buf0.reserve(len);
|
buf0.reserve(len);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public:
|
|||||||
result_type
|
result_type
|
||||||
operator()();
|
operator()();
|
||||||
|
|
||||||
static
|
static
|
||||||
result_type BEAST_CONSTEXPR
|
result_type BEAST_CONSTEXPR
|
||||||
min()
|
min()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -52,9 +52,9 @@ namespace beast {
|
|||||||
abbreviate the full templated name - e.g.
|
abbreviate the full templated name - e.g.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
|
|
||||||
using MyClassPtr = SharedPtr <MyClass>;
|
using MyClassPtr = SharedPtr <MyClass>;
|
||||||
|
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
@see SharedObject, SharedObjectArray
|
@see SharedObject, SharedObjectArray
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public:
|
|||||||
OutputDebugStringA ((s + "\n").c_str());
|
OutputDebugStringA ((s + "\n").c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << s << std::endl;
|
std::cout << s << std::endl;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
namespace beast
|
namespace beast
|
||||||
{
|
{
|
||||||
|
|
||||||
/** A scoped container that acquires a shared lock. */
|
/** A scoped container that acquires a shared lock. */
|
||||||
template <typename Mutex>
|
template <typename Mutex>
|
||||||
class SharedLockGuard
|
class SharedLockGuard
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
|
|
||||||
/** Adapts a regular Lockable to conform to the SharedMutex concept.
|
/** Adapts a regular Lockable to conform to the SharedMutex concept.
|
||||||
Shared locks become unique locks with this interface. Two threads may not
|
Shared locks become unique locks with this interface. Two threads may not
|
||||||
simultaneously acquire ownership of the lock. Typically the Mutex template
|
simultaneously acquire ownership of the lock. Typically the Mutex template
|
||||||
@@ -38,7 +38,7 @@ public:
|
|||||||
using MutexType = Mutex;
|
using MutexType = Mutex;
|
||||||
using LockGuardType = std::lock_guard <SharedMutexAdapter>;
|
using LockGuardType = std::lock_guard <SharedMutexAdapter>;
|
||||||
using SharedLockGuardType = SharedLockGuard <SharedMutexAdapter>;
|
using SharedLockGuardType = SharedLockGuard <SharedMutexAdapter>;
|
||||||
|
|
||||||
void lock() const
|
void lock() const
|
||||||
{
|
{
|
||||||
m_mutex.lock();
|
m_mutex.lock();
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class RootStoppable;
|
|||||||
This override is called for all Stoppable objects in the hierarchy
|
This override is called for all Stoppable objects in the hierarchy
|
||||||
during the prepare stage. It is guaranteed that all child Stoppable
|
during the prepare stage. It is guaranteed that all child Stoppable
|
||||||
objects have already been prepared when this is called.
|
objects have already been prepared when this is called.
|
||||||
|
|
||||||
Objects are called children first.
|
Objects are called children first.
|
||||||
|
|
||||||
4. start()
|
4. start()
|
||||||
@@ -127,7 +127,7 @@ class RootStoppable;
|
|||||||
funtion areChildrenStopped() can be used after children have stopped,
|
funtion areChildrenStopped() can be used after children have stopped,
|
||||||
but before the Stoppable logic itself has stopped, to determine if the
|
but before the Stoppable logic itself has stopped, to determine if the
|
||||||
stoppable's logic is a true stop.
|
stoppable's logic is a true stop.
|
||||||
|
|
||||||
Pseudo code for this process is as follows:
|
Pseudo code for this process is as follows:
|
||||||
|
|
||||||
@code
|
@code
|
||||||
@@ -236,7 +236,7 @@ private:
|
|||||||
onStop and onChildrenStopped will never be called concurrently, across
|
onStop and onChildrenStopped will never be called concurrently, across
|
||||||
all Stoppable objects descended from the same root, inclusive of the
|
all Stoppable objects descended from the same root, inclusive of the
|
||||||
root.
|
root.
|
||||||
|
|
||||||
It is safe to call isStopping, isStopped, and areChildrenStopped from
|
It is safe to call isStopping, isStopped, and areChildrenStopped from
|
||||||
within this function; The values returned will always be valid and never
|
within this function; The values returned will always be valid and never
|
||||||
change during the callback.
|
change during the callback.
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public:
|
|||||||
|
|
||||||
Thread (Thread const&) = delete;
|
Thread (Thread const&) = delete;
|
||||||
Thread& operator= (Thread const&) = delete;
|
Thread& operator= (Thread const&) = delete;
|
||||||
|
|
||||||
/** Destructor.
|
/** Destructor.
|
||||||
|
|
||||||
If the thread has not been stopped first, this will generate a fatal error.
|
If the thread has not been stopped first, this will generate a fatal error.
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ selector::operator() (suite_info const& s)
|
|||||||
The predicate checks the suite, module, and library fields of the
|
The predicate checks the suite, module, and library fields of the
|
||||||
suite_info in that order. When it finds a match, it changes modes
|
suite_info in that order. When it finds a match, it changes modes
|
||||||
depending on what was found:
|
depending on what was found:
|
||||||
|
|
||||||
If a suite is matched first, then only the suite is selected. The
|
If a suite is matched first, then only the suite is selected. The
|
||||||
suite may be marked manual.
|
suite may be marked manual.
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public:
|
|||||||
thread (suite& s, F&& f, Args&&... args)
|
thread (suite& s, F&& f, Args&&... args)
|
||||||
: s_ (&s)
|
: s_ (&s)
|
||||||
{
|
{
|
||||||
std::function<void(void)> b =
|
std::function<void(void)> b =
|
||||||
std::bind(std::forward<F>(f),
|
std::bind(std::forward<F>(f),
|
||||||
std::forward<Args>(args)...);
|
std::forward<Args>(args)...);
|
||||||
t_ = std::thread (&thread::run, this,
|
t_ = std::thread (&thread::run, this,
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#define BEAST_UTILITY_DEBUG_H_INCLUDED
|
#define BEAST_UTILITY_DEBUG_H_INCLUDED
|
||||||
|
|
||||||
#include <beast/strings/String.h>
|
#include <beast/strings/String.h>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
|
|
||||||
// Auxiliary outines for debugging
|
// Auxiliary outines for debugging
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ public:
|
|||||||
/** Returns `true` if sink logs anything at this stream's severity. */
|
/** Returns `true` if sink logs anything at this stream's severity. */
|
||||||
/** @{ */
|
/** @{ */
|
||||||
bool active() const;
|
bool active() const;
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
operator bool() const
|
operator bool() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ public:
|
|||||||
add (ss.str(), value);
|
add (ss.str(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Proxy operator[] (std::string const& key);
|
Proxy operator[] (std::string const& key);
|
||||||
|
|
||||||
Proxy operator[] (char const* key)
|
Proxy operator[] (char const* key)
|
||||||
{ return Proxy (*this, key); }
|
{ return Proxy (*this, key); }
|
||||||
@@ -364,7 +364,7 @@ public:
|
|||||||
|
|
||||||
static bool peel_leading_slash (std::string* path);
|
static bool peel_leading_slash (std::string* path);
|
||||||
static bool peel_trailing_slashstar (std::string* path);
|
static bool peel_trailing_slashstar (std::string* path);
|
||||||
static std::string peel_name(std::string* path);
|
static std::string peel_name(std::string* path);
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ public:
|
|||||||
log <<
|
log <<
|
||||||
"_DEBUG = " <<
|
"_DEBUG = " <<
|
||||||
String::fromNumber (envDebug ());
|
String::fromNumber (envDebug ());
|
||||||
|
|
||||||
log <<
|
log <<
|
||||||
"BEAST_DEBUG = " <<
|
"BEAST_DEBUG = " <<
|
||||||
String::fromNumber (beastDebug ());
|
String::fromNumber (beastDebug ());
|
||||||
|
|||||||
@@ -310,12 +310,12 @@ std::string PropertyStream::Source::peel_name (std::string* path)
|
|||||||
{
|
{
|
||||||
if (path->empty())
|
if (path->empty())
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
std::string::const_iterator first = (*path).begin();
|
std::string::const_iterator first = (*path).begin();
|
||||||
std::string::const_iterator last = (*path).end();
|
std::string::const_iterator last = (*path).end();
|
||||||
std::string::const_iterator pos (std::find (first, last, '/'));
|
std::string::const_iterator pos (std::find (first, last, '/'));
|
||||||
std::string s (first, pos);
|
std::string s (first, pos);
|
||||||
|
|
||||||
if (pos != last)
|
if (pos != last)
|
||||||
*path = std::string (pos+1, last);
|
*path = std::string (pos+1, last);
|
||||||
else
|
else
|
||||||
@@ -352,7 +352,7 @@ PropertyStream::Source* PropertyStream::Source::find_path (std::string path)
|
|||||||
break;
|
break;
|
||||||
source = source->find_one(name);
|
source = source->find_one(name);
|
||||||
}
|
}
|
||||||
while (source != nullptr);
|
while (source != nullptr);
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -636,7 +636,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_peel_trailing_slashstar (std::string s,
|
void test_peel_trailing_slashstar (std::string s,
|
||||||
std::string const& expected_remainder, bool should_be_found)
|
std::string const& expected_remainder, bool should_be_found)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -648,7 +648,7 @@ public:
|
|||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
fail ("unhandled exception");;
|
fail ("unhandled exception");;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_find_one (Source& root, Source* expected, std::string const& name)
|
void test_find_one (Source& root, Source* expected, std::string const& name)
|
||||||
@@ -692,7 +692,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_find (Source& root, std::string path, Source* expected,
|
void test_find (Source& root, std::string path, Source* expected,
|
||||||
bool expected_star)
|
bool expected_star)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -759,8 +759,8 @@ public:
|
|||||||
test_find_one (d, &f, "f");
|
test_find_one (d, &f, "f");
|
||||||
|
|
||||||
testcase ("find_path");
|
testcase ("find_path");
|
||||||
test_find_path (a, "a", nullptr);
|
test_find_path (a, "a", nullptr);
|
||||||
test_find_path (a, "e", nullptr);
|
test_find_path (a, "e", nullptr);
|
||||||
test_find_path (a, "a/b", nullptr);
|
test_find_path (a, "a/b", nullptr);
|
||||||
test_find_path (a, "a/b/e", nullptr);
|
test_find_path (a, "a/b/e", nullptr);
|
||||||
test_find_path (a, "b/e/g", nullptr);
|
test_find_path (a, "b/e/g", nullptr);
|
||||||
@@ -768,7 +768,7 @@ public:
|
|||||||
test_find_path (a, "b", &b);
|
test_find_path (a, "b", &b);
|
||||||
test_find_path (a, "b/e", &e);
|
test_find_path (a, "b/e", &e);
|
||||||
test_find_path (a, "b/d/f", &f);
|
test_find_path (a, "b/d/f", &f);
|
||||||
|
|
||||||
testcase ("find_one_deep");
|
testcase ("find_one_deep");
|
||||||
test_find_one_deep (a, "z", nullptr);
|
test_find_one_deep (a, "z", nullptr);
|
||||||
test_find_one_deep (a, "g", &g);
|
test_find_one_deep (a, "g", &g);
|
||||||
|
|||||||
@@ -71,16 +71,16 @@ struct enable_if_lvalue
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Ensure const reference function parameters are valid lvalues.
|
/** Ensure const reference function parameters are valid lvalues.
|
||||||
|
|
||||||
Some functions, especially class constructors, accept const references and
|
Some functions, especially class constructors, accept const references and
|
||||||
store them for later use. If any of those parameters are rvalue objects,
|
store them for later use. If any of those parameters are rvalue objects,
|
||||||
the object will be freed as soon as the function returns. This could
|
the object will be freed as soon as the function returns. This could
|
||||||
potentially lead to a variety of "use after free" errors.
|
potentially lead to a variety of "use after free" errors.
|
||||||
|
|
||||||
If the function is rewritten as a template using this type and the
|
If the function is rewritten as a template using this type and the
|
||||||
parameters references as rvalue references (eg. TX&&), a compiler
|
parameters references as rvalue references (eg. TX&&), a compiler
|
||||||
error will be generated if an rvalue is provided in the caller.
|
error will be generated if an rvalue is provided in the caller.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
// Example:
|
// Example:
|
||||||
struct X
|
struct X
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ static_initializer <T, Tag>::static_initializer (Args&&... args)
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
::new(t) T (std::forward<Args>(args)...);
|
::new(t) T (std::forward<Args>(args)...);
|
||||||
static destroyer on_exit (t);
|
static destroyer on_exit (t);
|
||||||
_InterlockedIncrement(&_.state);
|
_InterlockedIncrement(&_.state);
|
||||||
}
|
}
|
||||||
@@ -198,7 +198,7 @@ public:
|
|||||||
static_initializer (Args&&... args);
|
static_initializer (Args&&... args);
|
||||||
|
|
||||||
static_initializer ();
|
static_initializer ();
|
||||||
|
|
||||||
T&
|
T&
|
||||||
get() noexcept
|
get() noexcept
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public:
|
|||||||
sink.severity(Journal::kInfo);
|
sink.severity(Journal::kInfo);
|
||||||
|
|
||||||
Journal j(sink);
|
Journal j(sink);
|
||||||
|
|
||||||
j.trace << " ";
|
j.trace << " ";
|
||||||
expect(sink.count() == 0);
|
expect(sink.count() == 0);
|
||||||
j.debug << " ";
|
j.debug << " ";
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
|
|
||||||
class tagged_integer_test
|
class tagged_integer_test
|
||||||
: public unit_test::suite
|
: public unit_test::suite
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -112,7 +112,7 @@ public:
|
|||||||
|
|
||||||
expect (zero >= zero, "Should be greater than or equal");
|
expect (zero >= zero, "Should be greater than or equal");
|
||||||
expect (zero == zero, "Should be equal");
|
expect (zero == zero, "Should be equal");
|
||||||
|
|
||||||
expect (one > zero, "Should be greater");
|
expect (one > zero, "Should be greater");
|
||||||
expect (one >= zero, "Should be greater than or equal");
|
expect (one >= zero, "Should be greater than or equal");
|
||||||
expect (one != zero, "Should not be equal");
|
expect (one != zero, "Should not be equal");
|
||||||
@@ -140,7 +140,7 @@ public:
|
|||||||
expect(++tmp == one, "Should be equal");
|
expect(++tmp == one, "Should be equal");
|
||||||
|
|
||||||
tmp = zero;
|
tmp = zero;
|
||||||
|
|
||||||
tmp += 1u;
|
tmp += 1u;
|
||||||
expect(tmp == one, "Should be equal");
|
expect(tmp == one, "Should be equal");
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public:
|
|||||||
std::bind(weak_fn(&T::fi, p), 1)();
|
std::bind(weak_fn(&T::fi, p), 1)();
|
||||||
expect(called);
|
expect(called);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
bool called = false;
|
bool called = false;
|
||||||
auto p = std::make_shared<T>(called);
|
auto p = std::make_shared<T>(called);
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ public:
|
|||||||
if(auto p = object_.lock())
|
if(auto p = object_.lock())
|
||||||
return ((*p).*member_)(args...);
|
return ((*p).*member_)(args...);
|
||||||
return this->member()();
|
return this->member()();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // detail
|
} // detail
|
||||||
@@ -120,11 +120,11 @@ public:
|
|||||||
When called, it tries to lock weak_ptr to get a shared_ptr. If successful,
|
When called, it tries to lock weak_ptr to get a shared_ptr. If successful,
|
||||||
it calls given member function with given arguments. If not successful,
|
it calls given member function with given arguments. If not successful,
|
||||||
the policy functor is called. Built-in policies are:
|
the policy functor is called. Built-in policies are:
|
||||||
|
|
||||||
ignore_if_invalid does nothing
|
ignore_if_invalid does nothing
|
||||||
throw_if_invalid throws `bad_weak_ptr`
|
throw_if_invalid throws `bad_weak_ptr`
|
||||||
return_default_if_invalid returns a chosen value
|
return_default_if_invalid returns a chosen value
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
struct Foo {
|
struct Foo {
|
||||||
@@ -138,12 +138,12 @@ public:
|
|||||||
std::cout << "outdated reference" << std::endl;
|
std::cout << "outdated reference" << std::endl;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
std::shared_ptr<Foo> sp(new Foo());
|
std::shared_ptr<Foo> sp(new Foo());
|
||||||
std::weak_ptr<Foo> wp(sp);
|
std::weak_ptr<Foo> wp(sp);
|
||||||
|
|
||||||
std::bind(weak_fn(&Foo::bar, wp), _1)(1);
|
std::bind(weak_fn(&Foo::bar, wp), _1)(1);
|
||||||
sp.reset();
|
sp.reset();
|
||||||
std::bind(weak_fn(&Foo::bar, wp), 1)();
|
std::bind(weak_fn(&Foo::bar, wp), 1)();
|
||||||
|
|||||||
Reference in New Issue
Block a user