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

Function main

src/examples/rpp/doxygen/retry.cpp:9–30  ·  view source on GitHub ↗

* @example retry.cpp **/

Source from the content-addressed store, hash-verified

7 * @example retry.cpp
8 **/
9int main()
10{
11 //! [retry]
12 rpp::source::concat(rpp::source::just(1, 2, 3), rpp::source::error<int>({}))
13 | rpp::operators::retry(2)
14 | rpp::operators::subscribe([](int v) { std::cout << v << " "; },
15 [](const std::exception_ptr&) { std::cout << "error" << std::endl; },
16 []() { std::cout << "completed" << std::endl; });
17 // Output: 1 2 3 1 2 3 1 2 3 error
18 //! [retry]
19
20 //! [retry_infinitely]
21 rpp::source::concat(rpp::source::just(1, 2, 3), rpp::source::error<int>({}))
22 | rpp::operators::retry()
23 | rpp::operators::take(10)
24 | rpp::operators::subscribe([](int v) { std::cout << v << " "; },
25 [](const std::exception_ptr&) { std::cout << "error" << std::endl; },
26 []() { std::cout << "completed" << std::endl; });
27 // Output: 1 2 3 1 2 3 1 2 3 1 completed
28 //! [retry_infinitely]
29 return 0;
30}

Callers

nothing calls this directly

Calls 5

justFunction · 0.85
retryFunction · 0.85
subscribeFunction · 0.85
takeFunction · 0.85
concatFunction · 0.50

Tested by

no test coverage detected