Commit efb63e76 authored by Xavier Thompson's avatar Xavier Thompson

Move random.hpp to fundamental

parent 16921d8b
#ifndef TYPON_FUNDAMENTAL_RANDOM_HPP_INCLUDED
#define TYPON_FUNDAMENTAL_RANDOM_HPP_INCLUDED
#include <random>
namespace typon::fdt::random
{
static thread_local std::mt19937 random { std::random_device{}() };
}
#endif // TYPON_FUNDAMENTAL_RANDOM_HPP_INCLUDED
#ifndef TYPON_RANDOM_HPP_INCLUDED
#define TYPON_RANDOM_HPP_INCLUDED
#include <random>
namespace typon
{
struct Random
{
std::mt19937 _rng;
Random() noexcept : _rng{std::random_device{}()} {}
unsigned int operator()() noexcept
{
return _rng();
}
};
namespace random
{
static thread_local Random random;
}
}
#endif // TYPON_RANDOM_HPP_INCLUDED
......@@ -7,10 +7,11 @@
#include <thread>
#include <vector>
#include <typon/fundamental/random.hpp>
#include <typon/continuation.hpp>
#include <typon/eventcount.hpp>
#include <typon/deque.hpp>
#include <typon/random.hpp>
namespace typon
......@@ -117,7 +118,7 @@ namespace typon
{
for (uint i = 0; i < _parallelism * 2 + 1; i++)
{
uint id = random::random() % _parallelism;
uint id = fdt::random::random() % _parallelism;
if (id == thread_id)
{
task = _deque.back().steal();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment