MCPcopy Create free account
hub / github.com/AlexInLog/ReactivePlusPlus / main

Function main

src/examples/rpp/two_async_streams/two_async_streams.cpp:21–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19}
20
21int main() // NOLINT(bugprone-exception-escape)
22{
23 auto raw_keyboard_events = rpp::source::from_callable(&::getchar)
24 | rpp::operators::repeat()
25 | rpp::operators::subscribe_on(rpp::schedulers::new_thread{})
26 | rpp::operators::publish()
27 | rpp::operators::ref_count();
28
29 auto termination = raw_keyboard_events
30 | rpp::operators::filter([](char v) { return v == '0'; });
31
32 auto chars = raw_keyboard_events
33 | rpp::operators::filter([](char v) { return !std::isdigit(v) && v != '\n'; })
34 | rpp::operators::map(&::toupper)
35 | rpp::operators::map(format_message<char>);
36
37
38 start = rpp::schedulers::clock_type::now();
39 std::cout << format_message("main thread") << std::endl;
40
41 rpp::source::interval(std::chrono::seconds{1}, rpp::schedulers::new_thread{})
42 | rpp::operators::map([](size_t i) { return format_message(std::string{"counter "} + std::to_string(i)); })
43 | rpp::operators::merge_with(chars)
44 | rpp::operators::observe_on(rpp::schedulers::new_thread{})
45 | rpp::operators::take_until(termination)
46 | rpp::operators::as_blocking()
47 | rpp::operators::subscribe([](const std::string& event) {
48 std::cout << event << std::endl;
49 });
50
51 std::cout << "EXIT" << std::endl;
52
53 return 0;
54}

Callers

nothing calls this directly

Calls 15

from_callableFunction · 0.85
repeatFunction · 0.85
subscribe_onFunction · 0.85
publishFunction · 0.85
ref_countFunction · 0.85
filterFunction · 0.85
mapFunction · 0.85
nowFunction · 0.85
format_messageFunction · 0.85
intervalFunction · 0.85
merge_withFunction · 0.85
observe_onFunction · 0.85

Tested by

no test coverage detected