diff options
author | Grigoriy Chudnov <g.chudnov@gmail.com> | 2017-07-15 01:49:47 +0300 |
---|---|---|
committer | Kirk Shoop <kirk.shoop@microsoft.com> | 2017-07-14 15:49:47 -0700 |
commit | 5aea424898994b3d409db268486202244cfe5053 (patch) | |
tree | 3d0f93b34d0bacbc48c77db8486624b9110b0208 /Rx/v2/src/rxcpp/operators | |
parent | 1d75538fa780e530bcd724433257c65b3fe36b29 (diff) | |
download | RxCpp-5aea424898994b3d409db268486202244cfe5053.tar.gz |
fix timeout when no items are emitted (#387)
Diffstat (limited to 'Rx/v2/src/rxcpp/operators')
-rw-r--r-- | Rx/v2/src/rxcpp/operators/rx-timeout.hpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Rx/v2/src/rxcpp/operators/rx-timeout.hpp b/Rx/v2/src/rxcpp/operators/rx-timeout.hpp index 6750e34..841df12 100644 --- a/Rx/v2/src/rxcpp/operators/rx-timeout.hpp +++ b/Rx/v2/src/rxcpp/operators/rx-timeout.hpp @@ -126,6 +126,20 @@ struct timeout localState->cs.add([=](){ localState->worker.schedule(selectedDisposer.get()); }); + + auto work = [v, localState](const rxsc::schedulable&) { + auto new_id = ++localState->index; + auto produce_time = localState->worker.now() + localState->period; + + localState->worker.schedule(produce_time, produce_timeout(new_id, localState)); + }; + auto selectedWork = on_exception( + [&](){return localState->coordinator.act(work);}, + localState->dest); + if (selectedWork.empty()) { + return; + } + localState->worker.schedule(selectedWork.get()); } static std::function<void(const rxsc::schedulable&)> produce_timeout(std::size_t id, state_type state) { |