Commit 29e06858 authored by Dominik Charousset's avatar Dominik Charousset

Pick a sane default for run_dispatch_loop

parent 647ceea6
...@@ -116,14 +116,15 @@ public: ...@@ -116,14 +116,15 @@ public:
/// Loops until no job or delayed message remains or `predicate` returns /// Loops until no job or delayed message remains or `predicate` returns
/// `true`. Returns the total number of events (first) and dispatched delayed /// `true`. Returns the total number of events (first) and dispatched delayed
/// messages (second). Advances time by `cycle` between to calls to /// messages (second). Advances time by `cycle` nanoseconds between to calls
/// `dispatch()`. /// to `dispatch()` or the default tick-duration when passing 0ns.
std::pair<size_t, size_t> run_dispatch_loop(std::function<bool()> predicate, std::pair<size_t, size_t> run_dispatch_loop(std::function<bool()> predicate,
timespan cycle = timespan{0}); timespan cycle = timespan{0});
/// Loops until no job or delayed message remains. Returns the total number /// Loops until no job or delayed message remains. Returns the total number
/// of events (first) and dispatched delayed messages (second). Advances time /// of events (first) and dispatched delayed messages (second). Advances time
/// by `cycle` between to calls to `dispatch()`. /// by `cycle` nanoseconds between to calls to `dispatch()` or the default
/// tick-duration when passing 0ns.
std::pair<size_t, size_t> run_dispatch_loop(timespan cycle = timespan{0}); std::pair<size_t, size_t> run_dispatch_loop(timespan cycle = timespan{0});
template <class F> template <class F>
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "caf/resumable.hpp" #include "caf/resumable.hpp"
#include "caf/monitorable_actor.hpp" #include "caf/monitorable_actor.hpp"
#include "caf/actor_system_config.hpp"
namespace caf { namespace caf {
namespace scheduler { namespace scheduler {
...@@ -157,6 +158,10 @@ std::pair<size_t, size_t> ...@@ -157,6 +158,10 @@ std::pair<size_t, size_t>
test_coordinator::run_dispatch_loop(std::function<bool()> predicate, test_coordinator::run_dispatch_loop(std::function<bool()> predicate,
timespan cycle) { timespan cycle) {
std::pair<size_t, size_t> res{0, 0}; std::pair<size_t, size_t> res{0, 0};
if (cycle.count() == 0) {
auto x = system().config().streaming_tick_duration_us();
cycle = std::chrono::microseconds(x);
}
for (;;) { for (;;) {
size_t progress = 0; size_t progress = 0;
while (try_run_once()) { while (try_run_once()) {
......
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