Skip to content

Commit

Permalink
Use trunk version of rxcpp. Resolves #122 (#127)
Browse files Browse the repository at this point in the history
Signed-off-by: Arjo Chakravarty <[email protected]>
  • Loading branch information
arjo129 authored Sep 30, 2021
1 parent 78e85e6 commit 081b3e3
Show file tree
Hide file tree
Showing 131 changed files with 1,333 additions and 465 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ SCENARIO("implicit amb sample"){
printf("//! [implicit amb sample]\n");
}

std::string get_pid();
#include "main.hpp"

SCENARIO("threaded amb sample"){
printf("//! [threaded amb sample]\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ SCENARIO("buffer count+skip sample"){
printf("//! [buffer count+skip sample]\n");
}

std::string get_pid();
#include "main.hpp"

SCENARIO("buffer period+skip+coordination sample"){
printf("//! [buffer period+skip+coordination sample]\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ SCENARIO("combine_latest sample"){
printf("//! [combine_latest sample]\n");
}

std::string get_pid();
#include "main.hpp"

SCENARIO("Coordination combine_latest sample"){
printf("//! [Coordination combine_latest sample]\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace rxu=rxcpp::util;
#include "rxcpp/rx-test.hpp"
#include "catch.hpp"

#if RXCPP_USE_EXCEPTIONS
SCENARIO("composite_exception sample"){
printf("//! [composite_exception sample]\n");
auto o1 = rxcpp::observable<>::error<int>(std::runtime_error("Error from source o1\n"));
Expand All @@ -16,11 +17,11 @@ SCENARIO("composite_exception sample"){
[](std::exception_ptr composite_e) {
printf("OnError %s\n", rxu::what(composite_e).c_str());
try { std::rethrow_exception(composite_e); }
catch(rxcpp::composite_exception ce) {
catch(rxcpp::composite_exception const &ce) {
for(std::exception_ptr particular_e : ce.exceptions) {

try{ std::rethrow_exception(particular_e); }
catch(std::runtime_error error) { printf(" *** %s\n", error.what()); }
catch(std::runtime_error const &error) { printf(" *** %s\n", error.what()); }

}
}
Expand All @@ -29,3 +30,4 @@ SCENARIO("composite_exception sample"){
);
printf("//! [composite_exception sample]\n");
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SCENARIO("concat_map sample"){
printf("//! [concat_map sample]\n");
}

std::string get_pid();
#include "main.hpp"

SCENARIO("threaded concat_map sample"){
printf("//! [threaded concat_map sample]\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,8 @@ SCENARIO("Create great code"){
[](int v){
printf("OnNext: %d\n", v);
},
[](std::exception_ptr ep){
try {std::rethrow_exception(ep);}
catch (const std::exception& ex) {
printf("OnError: %s\n", ex.what());
}
[](rxcpp::util::error_ptr ep){
printf("OnError: %s\n", rxcpp::util::what(ep).c_str());
},
[](){
printf("OnCompleted\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ SCENARIO("error sample"){
values.
subscribe(
[](int v){printf("OnNext: %d\n", v);},
[](std::exception_ptr ep){
try {std::rethrow_exception(ep);}
catch (const std::exception& ex) {
printf("OnError: %s\n", ex.what());
}
[](rxcpp::util::error_ptr ep){
printf("OnError: %s\n", rxcpp::util::what(ep).c_str());
},
[](){printf("OnCompleted\n");});
printf("//! [error sample]\n");
Expand All @@ -26,11 +23,8 @@ SCENARIO("threaded error sample"){
as_blocking().
subscribe(
[](int v){printf("OnNext: %d\n", v);},
[](std::exception_ptr ep){
try {std::rethrow_exception(ep);}
catch (const std::exception& ex) {
printf("OnError: %s\n", ex.what());
}
[](rxcpp::util::error_ptr ep){
printf("OnError: %s\n", rxcpp::util::what(ep).c_str());
},
[](){printf("OnCompleted\n");});
printf("//! [threaded error sample]\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ SCENARIO("error finally sample"){
values.
subscribe(
[](int v){printf("OnNext: %d\n", v);},
[](std::exception_ptr ep){
try {std::rethrow_exception(ep);}
catch (const std::exception& ex) {
printf("OnError: %s\n", ex.what());
}
[](rxcpp::util::error_ptr ep){
printf("OnError: %s\n", rxcpp::util::what(ep).c_str());
},
[](){printf("OnCompleted\n");});
printf("//! [error finally sample]\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SCENARIO("flat_map sample"){
printf("//! [flat_map sample]\n");
}

std::string get_pid();
#include "main.hpp"

SCENARIO("threaded flat_map sample"){
printf("//! [threaded flat_map sample]\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SCENARIO("from sample"){
printf("//! [from sample]\n");
}

std::string get_pid();
#include "main.hpp"

SCENARIO("threaded from sample"){
printf("//! [threaded from sample]\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "rxcpp/rx-test.hpp"
#include "catch.hpp"

#include <sstream>

SCENARIO("group_by sample"){
printf("//! [group_by sample]\n");
auto values = rxcpp::observable<>::range(0, 8).
Expand All @@ -23,7 +25,7 @@ SCENARIO("group_by sample"){
}

//! [group_by full intro]
bool less(int v1, int v2){
static bool less(int v1, int v2){
return v1 < v2;
}
//! [group_by full intro]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#include <iostream>
#include <thread>
#include <string>

#include "main.hpp"

std::string get_pid() {
std::stringstream s;
s << std::this_thread::get_id();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

std::string get_pid();
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ SCENARIO("first sample"){
printf("//! [first sample]\n");
}

#if RXCPP_USE_EXCEPTIONS
SCENARIO("first empty sample"){
printf("//! [first empty sample]\n");
auto values = rxcpp::observable<>::empty<int>().first();
Expand All @@ -28,6 +29,7 @@ SCENARIO("first empty sample"){
[](){printf("OnCompleted\n");});
printf("//! [first empty sample]\n");
}
#endif

SCENARIO("last sample"){
printf("//! [last sample]\n");
Expand All @@ -39,6 +41,7 @@ SCENARIO("last sample"){
printf("//! [last sample]\n");
}

#if RXCPP_USE_EXCEPTIONS
SCENARIO("last empty sample"){
printf("//! [last empty sample]\n");
auto values = rxcpp::observable<>::empty<int>().last();
Expand All @@ -54,6 +57,7 @@ SCENARIO("last empty sample"){
[](){printf("OnCompleted\n");});
printf("//! [last empty sample]\n");
}
#endif

SCENARIO("count sample"){
printf("//! [count sample]\n");
Expand All @@ -65,6 +69,7 @@ SCENARIO("count sample"){
printf("//! [count sample]\n");
}

#if RXCPP_USE_EXCEPTIONS
SCENARIO("count error sample"){
printf("//! [count error sample]\n");
auto values = rxcpp::observable<>::range(1, 3).
Expand All @@ -82,6 +87,7 @@ SCENARIO("count error sample"){
[](){printf("OnCompleted\n");});
printf("//! [count error sample]\n");
}
#endif

SCENARIO("sum sample"){
printf("//! [sum sample]\n");
Expand All @@ -93,6 +99,7 @@ SCENARIO("sum sample"){
printf("//! [sum sample]\n");
}

#if RXCPP_USE_EXCEPTIONS
SCENARIO("sum empty sample"){
printf("//! [sum empty sample]\n");
auto values = rxcpp::observable<>::empty<int>().sum();
Expand All @@ -108,6 +115,7 @@ SCENARIO("sum empty sample"){
[](){printf("OnCompleted\n");});
printf("//! [sum empty sample]\n");
}
#endif

SCENARIO("sum error sample"){
printf("//! [sum error sample]\n");
Expand Down Expand Up @@ -137,6 +145,7 @@ SCENARIO("average sample"){
printf("//! [average sample]\n");
}

#if RXCPP_USE_EXCEPTIONS
SCENARIO("average empty sample"){
printf("//! [average empty sample]\n");
auto values = rxcpp::observable<>::empty<int>().average();
Expand All @@ -152,6 +161,7 @@ SCENARIO("average empty sample"){
[](){printf("OnCompleted\n");});
printf("//! [average empty sample]\n");
}
#endif

SCENARIO("average error sample"){
printf("//! [average error sample]\n");
Expand Down Expand Up @@ -181,6 +191,7 @@ SCENARIO("max sample"){
printf("//! [max sample]\n");
}

#if RXCPP_USE_EXCEPTIONS
SCENARIO("max empty sample"){
printf("//! [max empty sample]\n");
auto values = rxcpp::observable<>::empty<int>().max();
Expand All @@ -196,6 +207,7 @@ SCENARIO("max empty sample"){
[](){printf("OnCompleted\n");});
printf("//! [max empty sample]\n");
}
#endif

SCENARIO("max error sample"){
printf("//! [max error sample]\n");
Expand Down Expand Up @@ -225,6 +237,7 @@ SCENARIO("min sample"){
printf("//! [min sample]\n");
}

#if RXCPP_USE_EXCEPTIONS
SCENARIO("min empty sample"){
printf("//! [min empty sample]\n");
auto values = rxcpp::observable<>::empty<int>().min();
Expand All @@ -240,6 +253,7 @@ SCENARIO("min empty sample"){
[](){printf("OnCompleted\n");});
printf("//! [min empty sample]\n");
}
#endif

SCENARIO("min error sample"){
printf("//! [min error sample]\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ SCENARIO("implicit merge sample"){
printf("//! [implicit merge sample]\n");
}

std::string get_pid();
#include "main.hpp"

SCENARIO("threaded merge sample"){
printf("//! [threaded merge sample]\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ namespace rxu=rxcpp::util;
#include "rxcpp/rx-test.hpp"
#include "catch.hpp"

#include <sstream>

SCENARIO("merge_delay_error sample"){
printf("//! [merge_delay_error sample]\n");
auto o1 = rxcpp::observable<>::timer(std::chrono::milliseconds(15)).map([](int) {return 1;});
Expand Down Expand Up @@ -33,24 +35,24 @@ SCENARIO("implicit merge_delay_error sample"){
printf("//! [implicit merge_delay_error sample]\n");
}

std::string get_pid();
#include "main.hpp"

SCENARIO("threaded merge_delay_error sample"){
printf("//! [threaded merge_delay_error sample]\n");
printf("[thread %s] Start task\n", get_pid().c_str());
auto o1 = rxcpp::observable<>::timer(std::chrono::milliseconds(10)).map([](int) {
auto o1 = rxcpp::observable<>::timer(std::chrono::milliseconds(10)).map([](long) -> long {
printf("[thread %s] Timer1 fired\n", get_pid().c_str());
return 1;
});
auto o2 = rxcpp::observable<>::timer(std::chrono::milliseconds(20)).flat_map([](int) {
auto o2 = rxcpp::observable<>::timer(std::chrono::milliseconds(20)).flat_map([](long) -> rxcpp::observable<long> {
std::stringstream ss;
ss << "[thread " << get_pid().c_str() << "] Timer2 failed\n";
printf("%s\n", ss.str().c_str());
ss.str(std::string());
ss << "(Error from thread: " << get_pid().c_str() << ")\n";
return rxcpp::observable<>::error<int>(std::runtime_error(ss.str()));
return rxcpp::observable<>::error<long>(std::runtime_error(ss.str()));
});
auto o3 = rxcpp::observable<>::timer(std::chrono::milliseconds(30)).map([](int) {
auto o3 = rxcpp::observable<>::timer(std::chrono::milliseconds(30)).map([](long) -> long {
printf("[thread %s] Timer3 fired\n", get_pid().c_str());
return 3;
});
Expand All @@ -68,19 +70,19 @@ SCENARIO("threaded merge_delay_error sample"){
SCENARIO("threaded implicit merge_delay_error sample"){
printf("//! [threaded implicit merge_delay_error sample]\n");
printf("[thread %s] Start task\n", get_pid().c_str());
auto o1 = rxcpp::observable<>::timer(std::chrono::milliseconds(10)).map([](int) {
auto o1 = rxcpp::observable<>::timer(std::chrono::milliseconds(10)).map([](long) -> long {
printf("[thread %s] Timer1 fired\n", get_pid().c_str());
return 1;
});
auto o2 = rxcpp::observable<>::timer(std::chrono::milliseconds(20)).flat_map([](int) {
auto o2 = rxcpp::observable<>::timer(std::chrono::milliseconds(20)).flat_map([](long) -> rxcpp::observable<long> {
std::stringstream ss;
ss << "[thread " << get_pid().c_str() << "] Timer2 failed\n";
printf("%s\n", ss.str().c_str());
ss.str(std::string());
ss << "(Error from thread: " << get_pid().c_str() << ")\n";
return rxcpp::observable<>::error<int>(std::runtime_error(ss.str()));
return rxcpp::observable<>::error<long>(std::runtime_error(ss.str()));
});
auto o3 = rxcpp::observable<>::timer(std::chrono::milliseconds(30)).map([](int) {
auto o3 = rxcpp::observable<>::timer(std::chrono::milliseconds(30)).map([](long) -> long {
printf("[thread %s] Timer3 fired\n", get_pid().c_str());
return 3;
});
Expand All @@ -89,7 +91,7 @@ SCENARIO("threaded implicit merge_delay_error sample"){
values.
as_blocking().
subscribe(
[](int v){printf("[thread %s] OnNext: %d\n", get_pid().c_str(), v);},
[](long v){printf("[thread %s] OnNext: %ld\n", get_pid().c_str(), v);},
[](std::exception_ptr eptr) { printf("[thread %s] OnError %s\n", get_pid().c_str(), rxu::what(eptr).c_str()); },
[](){printf("[thread %s] OnCompleted\n", get_pid().c_str());});
printf("[thread %s] Finish task\n", get_pid().c_str());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "rxcpp/rx-test.hpp"
#include "catch.hpp"

std::string get_pid();
#include "main.hpp"

SCENARIO("observe_on sample"){
printf("//! [observe_on sample]\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SCENARIO("pairwise short sample"){
printf("//! [pairwise short sample]\n");
}

//std::string get_pid();
//#include "main.hpp"
//
//SCENARIO("threaded flat_map sample"){
// printf("//! [threaded flat_map sample]\n");
Expand Down
Loading

0 comments on commit 081b3e3

Please sign in to comment.