diff options
Diffstat (limited to 'boost/beast/websocket/detail/prng.hpp')
-rw-r--r-- | boost/beast/websocket/detail/prng.hpp | 79 |
1 files changed, 3 insertions, 76 deletions
diff --git a/boost/beast/websocket/detail/prng.hpp b/boost/beast/websocket/detail/prng.hpp index 35409b5837..6eb474f2f0 100644 --- a/boost/beast/websocket/detail/prng.hpp +++ b/boost/beast/websocket/detail/prng.hpp @@ -11,8 +11,8 @@ #define BOOST_BEAST_WEBSOCKET_DETAIL_PRNG_HPP #include <boost/beast/core/detail/config.hpp> +#include <boost/config.hpp> #include <cstdint> -#include <limits> #include <random> namespace boost { @@ -20,66 +20,7 @@ namespace beast { namespace websocket { namespace detail { -// Type-erased UniformRandomBitGenerator -// with 32-bit unsigned integer value_type -// -class prng -{ -protected: - virtual ~prng() = default; - virtual prng& acquire() noexcept = 0; - virtual void release() noexcept = 0; - virtual std::uint32_t operator()() noexcept = 0; - -public: - using value_type = std::uint32_t; - - class ref - { - prng& p_; - - public: - ref& operator=(ref const&) = delete; - - ~ref() - { - p_.release(); - } - - explicit - ref(prng& p) noexcept - : p_(p.acquire()) - { - } - - ref(ref const& other) noexcept - : p_(other.p_.acquire()) - { - } - - value_type - operator()() noexcept - { - return p_(); - } - - static - value_type constexpr - min() noexcept - { - return (std::numeric_limits< - value_type>::min)(); - } - - static - value_type constexpr - max() noexcept - { - return (std::numeric_limits< - value_type>::max)(); - } - }; -}; +using generator = std::uint32_t(*)(); //------------------------------------------------------------------------------ @@ -90,25 +31,11 @@ BOOST_BEAST_DECL std::uint32_t const* prng_seed(std::seed_seq* ss = nullptr); -// Acquire a PRNG using the no-TLS implementation -// -BOOST_BEAST_DECL -prng::ref -make_prng_no_tls(bool secure); - -// Acquire a PRNG using the TLS implementation -// -#ifndef BOOST_NO_CXX11_THREAD_LOCAL -BOOST_BEAST_DECL -prng::ref -make_prng_tls(bool secure); -#endif - // Acquire a PRNG using the TLS implementation if it // is available, otherwise using the no-TLS implementation. // BOOST_BEAST_DECL -prng::ref +generator make_prng(bool secure); } // detail |