ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
take_until.cpp
#include <rpp/rpp.hpp>
#include <chrono>
#include <iostream>
int main()
{
rpp::source::interval(std::chrono::seconds{1}, rpp::schedulers::trampoline{})
.take_until(rpp::source::interval(std::chrono::seconds{5}, rpp::schedulers::trampoline{}))
.subscribe([](int v) { std::cout << "-" << v; },
[](const std::exception_ptr&) { std::cout << "-x" << std::endl; },
[]() { std::cout << "-|" << std::endl; });
// source 1: -0-1-2-3-4-5-6-7- --
// source 2: ---------0---------1- --
// Output : -0-1-2-3-|
rpp::source::never<int>()
.take_until(rpp::source::error<bool>(std::make_exception_ptr(std::runtime_error{""})))
.subscribe([](int v) { std::cout << "-" << v; },
[](const std::exception_ptr&) { std::cout << "-x" << std::endl; },
[]() { std::cout << "-|" << std::endl; });
// source 1: -
// source 2: -x
// Output : -x
return 0;
}
Schedules execution of schedulables via queueing tasks to the caller thread with priority to time_poi...
Definition: trampoline_scheduler.hpp:41