forked from boostorg/beast
Simplify websocket::detail::prng:
- Use a regular function pointer for dynamic dispatch. - Remove `prng::ref` - it did not benefit the default case (TLS avaialable) and actually made the no-TLS case slower, because the time spent in the generator is dominated by mutex locking. Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>
This commit is contained in:
1 parent
a7e932b13c
commit
5f0939e771
5 files changed
+81
-325
No files matched your search
@@ -42,17 +42,20 @@ public:
|
||||
void
|
||||
testPrng(F const& f)
|
||||
{
|
||||
auto const min = std::numeric_limits<std::uint32_t>::min();
|
||||
auto const max = std::numeric_limits<std::uint32_t>::max();
|
||||
|
||||
{
|
||||
auto v = f()();
|
||||
BEAST_EXPECT(
|
||||
v >= (prng::ref::min)() &&
|
||||
v <= (prng::ref::max)());
|
||||
v >= min &&
|
||||
v <= max);
|
||||
}
|
||||
{
|
||||
auto v = f()();
|
||||
BEAST_EXPECT(
|
||||
v >= (prng::ref::min)() &&
|
||||
v <= (prng::ref::max)());
|
||||
v >= min &&
|
||||
v <= max);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,12 +64,6 @@ public:
|
||||
{
|
||||
testPrng([]{ return make_prng(true); });
|
||||
testPrng([]{ return make_prng(false); });
|
||||
testPrng([]{ return make_prng_no_tls(true); });
|
||||
testPrng([]{ return make_prng_no_tls(false); });
|
||||
#ifndef BOOST_NO_CXX11_THREAD_LOCAL
|
||||
testPrng([]{ return make_prng_tls(true); });
|
||||
testPrng([]{ return make_prng_tls(false); });
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user