Commit 7d8b0e13 authored by Dominik Charousset's avatar Dominik Charousset

Use std::random_device instead of rand()

parent e4741682
...@@ -2,9 +2,11 @@ ...@@ -2,9 +2,11 @@
* This example illustrates how to use aout. * * This example illustrates how to use aout. *
\ ******************************************************************************/ \ ******************************************************************************/
#include <random>
#include <chrono> #include <chrono>
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>
#include "caf/all.hpp" #include "caf/all.hpp"
using namespace caf; using namespace caf;
...@@ -16,7 +18,9 @@ int main() { ...@@ -16,7 +18,9 @@ int main() {
spawn<blocking_api>([i](blocking_actor* self) { spawn<blocking_api>([i](blocking_actor* self) {
aout(self) << "Hi there! This is actor nr. " aout(self) << "Hi there! This is actor nr. "
<< i << "!" << endl; << i << "!" << endl;
std::chrono::milliseconds tout{std::rand() % 1000}; std::random_device rd;
std::default_random_engine re(rd());
std::chrono::milliseconds tout{re() % 10};
self->delayed_send(self, tout, atom("done")); self->delayed_send(self, tout, atom("done"));
self->receive(others() >> [i, self] { self->receive(others() >> [i, self] {
aout(self) << "Actor nr. " aout(self) << "Actor nr. "
......
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