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

Function main

src/examples/rpp/doxygen/subscribe_on.cpp:8–29  ·  view source on GitHub ↗

* @example subscribe_on.cpp **/

Source from the content-addressed store, hash-verified

6 * @example subscribe_on.cpp
7 **/
8int main()
9{
10 //! [subscribe_on]
11 std::cout << std::this_thread::get_id() << std::endl;
12 rpp::source::create<int>([](const auto& sub) {
13 std::cout << "on_subscribe thread " << std::this_thread::get_id() << std::endl;
14 sub.on_next(1);
15 sub.on_completed();
16 })
17 | rpp::operators::subscribe_on(rpp::schedulers::new_thread{})
18 | rpp::operators::as_blocking()
19 | rpp::operators::subscribe([](int v) { std::cout << "[" << std::this_thread::get_id() << "] : " << v << "\n"; });
20 std::cout << std::this_thread::get_id() << std::endl;
21
22 // Template for output:
23 // TH1
24 // on_subscribe thread TH2
25 // [TH2]: 1
26 // TH1
27 //! [subscribe_on]
28 return 0;
29}

Callers

nothing calls this directly

Calls 5

subscribe_onFunction · 0.85
as_blockingFunction · 0.85
subscribeFunction · 0.85
on_nextMethod · 0.45
on_completedMethod · 0.45

Tested by

no test coverage detected