Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 497954ba authored by GMYS Jan's avatar GMYS Jan
Browse files

fix random ws

parent 90f46ae1
Branches
No related tags found
No related merge requests found
......@@ -44,18 +44,11 @@ class RandomVictimSelector : public VictimSelector
{
public:
explicit RandomVictimSelector(unsigned _nthreads) : VictimSelector(_nthreads),random_engine((std::random_device())())
{
// auto seed = static_cast<long int>(std::time(nullptr));
// random_engine = std::mt19937(size_t(seed));
// generator = std::random_device{ } ();
// unif = std::uniform_int_distribution<int>(0,nthreads-1);
};
{};
unsigned operator()(unsigned id)
{
unsigned victim = (id == 0) ? (nthreads - 1) : (id - 1);
// unsigned int attempts = 0;
std::uniform_int_distribution<int>unif(0,nthreads-1);
do {
......@@ -63,22 +56,15 @@ public:
victim = unif(random_engine);
if((victim<0)||(victim>=nthreads)){
std::cout<<"rand out of bounds :"<<victim<<" >= "<<nthreads<<"\n";
std::cout<<"victim select - rand is out of bounds :"<<victim<<" >= "<<nthreads<<"\n";
exit(-1);
}
// rand() / (RAND_MAX / nthreads);
// if(++attempts > nthreads){
// break;
// }
}while(victim == id);
return victim;
}
private:
// std::random_device random_device;
std::mt19937 random_engine;
// std::uniform_int_distribution<int> unif;
};
class HonestVictimSelector : public VictimSelector
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment