• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "rxcpp/rx.hpp"
2 
3 #include "rxcpp/rx-test.hpp"
4 #include "catch.hpp"
5 
6 #include "main.hpp"
7 
8 SCENARIO("subscribe_on sample"){
9     printf("//! [subscribe_on sample]\n");
10     printf("[thread %s] Start task\n", get_pid().c_str());
11     auto values = rxcpp::observable<>::range(1, 3).
__anon391bf38d0102(int v)12         map([](int v){
13             printf("[thread %s] Emit value %d\n", get_pid().c_str(), v);
14             return v;
15         });
16     values.
17         subscribe_on(rxcpp::synchronize_new_thread()).
18         as_blocking().
19         subscribe(
__anon391bf38d0202(int v)20             [](int v){printf("[thread %s] OnNext: %d\n", get_pid().c_str(), v);},
__anon391bf38d0302()21             [](){printf("[thread %s] OnCompleted\n", get_pid().c_str());});
22     printf("[thread %s] Finish task\n", get_pid().c_str());
23     printf("//! [subscribe_on sample]\n");
24 }
25