| 9 | **/ |
| 10 | |
| 11 | int main() // NOLINT(bugprone-exception-escape) |
| 12 | { |
| 13 | { |
| 14 | //! [fallback_observable] |
| 15 | auto start = rpp::schedulers::clock_type::now(); |
| 16 | |
| 17 | rpp::source::just(10, 30, 90, 110) |
| 18 | | rpp::operators::flat_map([](int v) { |
| 19 | return rpp::source::just(v) | rpp::operators::delay(std::chrono::milliseconds{v}, rpp::schedulers::current_thread{}); |
| 20 | }) |
| 21 | | rpp::operators::timeout(std::chrono::milliseconds{35}, rpp::source::just(rpp::schedulers::immediate{}, 0), rpp::schedulers::new_thread{}) |
| 22 | | rpp::operators::as_blocking() |
| 23 | | rpp::operators::subscribe([start](int v) { std::cout << "received " << v << " at " << std::chrono::duration_cast<std::chrono::milliseconds>(rpp::schedulers::clock_type::now() - start).count() << std::endl; }, |
| 24 | [start](const std::exception_ptr&) { |
| 25 | std::cout << "received error at " << std::chrono::duration_cast<std::chrono::milliseconds>(rpp::schedulers::clock_type::now() - start).count() << std::endl; |
| 26 | }); |
| 27 | //! [fallback_observable] |
| 28 | } |
| 29 | |
| 30 | { |
| 31 | //! [default] |
| 32 | auto start = rpp::schedulers::clock_type::now(); |
| 33 | |
| 34 | rpp::source::just(10, 30, 90, 110) |
| 35 | | rpp::operators::flat_map([](int v) { |
| 36 | return rpp::source::just(v) | rpp::operators::delay(std::chrono::milliseconds{v}, rpp::schedulers::current_thread{}); |
| 37 | }) |
| 38 | | rpp::operators::timeout(std::chrono::milliseconds{35}, rpp::schedulers::new_thread{}) |
| 39 | | rpp::operators::as_blocking() |
| 40 | | rpp::operators::subscribe([start](int v) { std::cout << "received " << v << " at " << std::chrono::duration_cast<std::chrono::milliseconds>(rpp::schedulers::clock_type::now() - start).count() << std::endl; }, |
| 41 | [start](const std::exception_ptr&) { |
| 42 | std::cout << "received error at " << std::chrono::duration_cast<std::chrono::milliseconds>(rpp::schedulers::clock_type::now() - start).count() << std::endl; |
| 43 | }); |
| 44 | //! [default] |
| 45 | } |
| 46 | } |