diff options
author | Igor Murashkin <iam@google.com> | 2019-02-20 13:52:07 -0800 |
---|---|---|
committer | Igor Murashkin <iam@google.com> | 2019-02-20 13:52:07 -0800 |
commit | bf1edc83fbbcb99293c1ef12d1c057dd38577914 (patch) | |
tree | 30696c133fbbe4ac173b40626b1515929dc7ced6 | |
parent | 2f3177dd770845c830419ef07b1b90a5a24d0649 (diff) | |
parent | aac2fc97bc5fe680446afb5ae81bef0a9c0fbf8a (diff) | |
download | platform_external_Reactive-Extensions_RxCpp-bf1edc83fbbcb99293c1ef12d1c057dd38577914.tar.gz platform_external_Reactive-Extensions_RxCpp-bf1edc83fbbcb99293c1ef12d1c057dd38577914.tar.bz2 platform_external_Reactive-Extensions_RxCpp-bf1edc83fbbcb99293c1ef12d1c057dd38577914.zip |
android: Merge branch 'upstream-master' into master
Updates to aac2fc97bc5fe680446afb5ae81bef0a9c0fbf8a in upstream.
Change-Id: Ic56ec9d83b5611e734dfdbebec7c3538388f5c82
51 files changed, 312 insertions, 128 deletions
diff --git a/.travis.yml b/.travis.yml index 20a2197..db24163 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,15 +10,15 @@ env: matrix: include: - - env: BUILD_TYPE=Debug ASAN=Off RUN_TEST=On + - env: BUILD_TYPE=Debug ASAN=Off RUN_TEST=On EXCEPTIONS=On os: osx osx_image: xcode8 - - env: BUILD_TYPE=Debug ASAN=Off LLVM_VERSION=3.8.0 RUN_TEST=On + - env: BUILD_TYPE=Debug ASAN=Off LLVM_VERSION=3.8.0 RUN_TEST=On EXCEPTIONS=On os: linux compiler: clang - - env: BUILD_TYPE=Release ASAN=Off GCC_VERSION=4.9 RUN_TEST=On + - env: BUILD_TYPE=Release ASAN=Off GCC_VERSION=4.9 RUN_TEST=On EXCEPTIONS=On os: linux compiler: gcc addons: @@ -28,7 +28,37 @@ matrix: sources: - ubuntu-toolchain-r-test - - env: BUILD_TYPE=Debug ASAN=Off LLVM_VERSION=3.8.0 RUN_TEST=Off PROJECT=doc PUBLISH_DOCS=On DOXYGEN_VERSION=1.8.11 + - env: BUILD_TYPE=Release ASAN=Off GCC_VERSION=7 RUN_TEST=On EXCEPTIONS=On + os: linux + compiler: gcc + addons: &gcc7 + apt: + packages: + - g++-7 + sources: + - ubuntu-toolchain-r-test + + - env: BUILD_TYPE=Debug ASAN=Off GCC_VERSION=8 RUN_TEST=On EXCEPTIONS=Off + os: linux + compiler: gcc + addons: &gcc8 + apt: + packages: + - g++-8 + sources: + - ubuntu-toolchain-r-test + + - env: BUILD_TYPE=Release ASAN=Off GCC_VERSION=8 RUN_TEST=On EXCEPTIONS=On + os: linux + compiler: gcc + addons: &gcc8 + apt: + packages: + - g++-8 + sources: + - ubuntu-toolchain-r-test + + - env: BUILD_TYPE=Debug ASAN=Off LLVM_VERSION=3.8.0 RUN_TEST=Off EXCEPTIONS=On PROJECT=doc PUBLISH_DOCS=On DOXYGEN_VERSION=1.8.11 os: linux compiler: clang addons: @@ -96,7 +126,7 @@ install: if [ -n "$DOXYGEN_VERSION" ]; then DOXYGEN_DIR=${DEPS_DIR}/doxygen-${DOXYGEN_VERSION} if [[ -z "$(ls -A ${DOXYGEN_DIR})" ]]; then - DOXYGEN_URL="http://ftp.stack.nl/pub/users/dimitri/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz" + DOXYGEN_URL="https://downloads.sourceforge.net/doxygen/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz" mkdir -p ${DOXYGEN_DIR} && travis_retry wget --quiet -O - ${DOXYGEN_URL} | tar --strip-components=1 -xz -C ${DOXYGEN_DIR} fi export PATH=${DOXYGEN_DIR}/bin:${PATH} @@ -127,6 +157,9 @@ before_script: if [ -z "$BUILD_TYPE" ]; then BUILD_TYPE=Release; fi; + if [ -z "$EXCEPTIONS" ]; then + EXCEPTIONS=On; + fi; if [[ "${ASAN}" == "On" ]]; then export CXXFLAGS="${CXXFLAGS} -fsanitize=address,undefined,integer -fno-omit-frame-pointer -fno-sanitize=unsigned-integer-overflow"; fi; @@ -138,7 +171,7 @@ before_script: # generate build ############################################################################ - cd ${TRAVIS_BUILD_DIR} - - cmake . -DCMAKE_BUILD_TYPE=$BUILD_TYPE + - cmake . -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DRX_USE_EXCEPTIONS=${EXCEPTIONS} script: ############################################################################ @@ -6,13 +6,13 @@ description: third_party { url { type: HOMEPAGE - value: "https://github.com/Reactive-Extensions/RxCpp/" + value: "https://github.com/ReactiveX/RxCpp/" } url { type: GIT - value: "https://github.com/Reactive-Extensions/RxCpp.git" + value: "https://github.com/ReactiveX/RxCpp.git" } - version: "a7d5856385f126e874db6010d9dbfd37290c61de" - last_upgrade_date { year: 2018 month: 8 day: 10 } + version: "aac2fc97bc5fe680446afb5ae81bef0a9c0fbf8a" + last_upgrade_date { year: 2019 month: 2 day: 20 } license_type: NOTICE } @@ -169,12 +169,12 @@ cd projects/build cmake -G"Xcode" ../CMake -B. ``` -#### Visual Studio 2013 +#### Visual Studio 2017 ```batch mkdir projects\build cd projects\build -cmake -G"Visual Studio 14" ..\CMake -B. -msbuild rxcpp.sln +cmake -G "Visual Studio 15" ..\CMake\ +msbuild Project.sln ``` ### makefile builds @@ -191,7 +191,7 @@ make ```shell mkdir projects/build cd projects/build -cmake -G"Unix Makefiles" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=RelWithDebInfo -B. ../CMake +cmake -G"Unix Makefiles" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_EXE_LINKER_FLAGS="-stdlib=libc++" -B. ../CMake make ``` diff --git a/Rx/v2/examples/doxygen/amb.cpp b/Rx/v2/examples/doxygen/amb.cpp index e7dfaa6..eab7f7e 100644 --- a/Rx/v2/examples/doxygen/amb.cpp +++ b/Rx/v2/examples/doxygen/amb.cpp @@ -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"); diff --git a/Rx/v2/examples/doxygen/buffer.cpp b/Rx/v2/examples/doxygen/buffer.cpp index 58f023a..503db12 100644 --- a/Rx/v2/examples/doxygen/buffer.cpp +++ b/Rx/v2/examples/doxygen/buffer.cpp @@ -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"); diff --git a/Rx/v2/examples/doxygen/combine_latest.cpp b/Rx/v2/examples/doxygen/combine_latest.cpp index b220da4..5f2168b 100644 --- a/Rx/v2/examples/doxygen/combine_latest.cpp +++ b/Rx/v2/examples/doxygen/combine_latest.cpp @@ -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"); diff --git a/Rx/v2/examples/doxygen/composite_exception.cpp b/Rx/v2/examples/doxygen/composite_exception.cpp index 6cbfce3..00f351d 100644 --- a/Rx/v2/examples/doxygen/composite_exception.cpp +++ b/Rx/v2/examples/doxygen/composite_exception.cpp @@ -17,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()); } } } diff --git a/Rx/v2/examples/doxygen/concat_map.cpp b/Rx/v2/examples/doxygen/concat_map.cpp index 957665f..a087431 100644 --- a/Rx/v2/examples/doxygen/concat_map.cpp +++ b/Rx/v2/examples/doxygen/concat_map.cpp @@ -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"); diff --git a/Rx/v2/examples/doxygen/create.cpp b/Rx/v2/examples/doxygen/create.cpp index c2886c2..1f707c6 100644 --- a/Rx/v2/examples/doxygen/create.cpp +++ b/Rx/v2/examples/doxygen/create.cpp @@ -90,8 +90,8 @@ SCENARIO("Create great code"){ [](int v){ printf("OnNext: %d\n", v); }, - [](rxcpp::error_ptr ep){ - printf("OnError: %s\n", rxu::what(ep)); + [](rxcpp::util::error_ptr ep){ + printf("OnError: %s\n", rxcpp::util::what(ep).c_str()); }, [](){ printf("OnCompleted\n"); diff --git a/Rx/v2/examples/doxygen/error.cpp b/Rx/v2/examples/doxygen/error.cpp index 7600b94..87b5b78 100644 --- a/Rx/v2/examples/doxygen/error.cpp +++ b/Rx/v2/examples/doxygen/error.cpp @@ -9,8 +9,8 @@ SCENARIO("error sample"){ values. subscribe( [](int v){printf("OnNext: %d\n", v);}, - [](rxcpp::error_ptr ep){ - printf("OnError: %s\n", rxu::what(ep)); + [](rxcpp::util::error_ptr ep){ + printf("OnError: %s\n", rxcpp::util::what(ep).c_str()); }, [](){printf("OnCompleted\n");}); printf("//! [error sample]\n"); @@ -23,8 +23,8 @@ SCENARIO("threaded error sample"){ as_blocking(). subscribe( [](int v){printf("OnNext: %d\n", v);}, - [](rxcpp::error_ptr ep){ - printf("OnError: %s\n", rxu::what(ep)); + [](rxcpp::util::error_ptr ep){ + printf("OnError: %s\n", rxcpp::util::what(ep).c_str()); }, [](){printf("OnCompleted\n");}); printf("//! [threaded error sample]\n"); diff --git a/Rx/v2/examples/doxygen/finally.cpp b/Rx/v2/examples/doxygen/finally.cpp index d947320..253d3a9 100644 --- a/Rx/v2/examples/doxygen/finally.cpp +++ b/Rx/v2/examples/doxygen/finally.cpp @@ -26,8 +26,8 @@ SCENARIO("error finally sample"){ values. subscribe( [](int v){printf("OnNext: %d\n", v);}, - [](rxcpp::error_ptr ep){ - printf("OnError: %s\n", rxu::what(ep)); + [](rxcpp::util::error_ptr ep){ + printf("OnError: %s\n", rxcpp::util::what(ep).c_str()); }, [](){printf("OnCompleted\n");}); printf("//! [error finally sample]\n"); diff --git a/Rx/v2/examples/doxygen/flat_map.cpp b/Rx/v2/examples/doxygen/flat_map.cpp index 0c88cbe..3e0a09f 100644 --- a/Rx/v2/examples/doxygen/flat_map.cpp +++ b/Rx/v2/examples/doxygen/flat_map.cpp @@ -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"); diff --git a/Rx/v2/examples/doxygen/from.cpp b/Rx/v2/examples/doxygen/from.cpp index 15186ba..7cc2276 100644 --- a/Rx/v2/examples/doxygen/from.cpp +++ b/Rx/v2/examples/doxygen/from.cpp @@ -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"); diff --git a/Rx/v2/examples/doxygen/group_by.cpp b/Rx/v2/examples/doxygen/group_by.cpp index d30f334..74ef859 100644 --- a/Rx/v2/examples/doxygen/group_by.cpp +++ b/Rx/v2/examples/doxygen/group_by.cpp @@ -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). @@ -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] diff --git a/Rx/v2/examples/doxygen/main.cpp b/Rx/v2/examples/doxygen/main.cpp index 8a831f2..4da59c5 100644 --- a/Rx/v2/examples/doxygen/main.cpp +++ b/Rx/v2/examples/doxygen/main.cpp @@ -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(); diff --git a/Rx/v2/examples/doxygen/main.hpp b/Rx/v2/examples/doxygen/main.hpp new file mode 100644 index 0000000..7439c6a --- /dev/null +++ b/Rx/v2/examples/doxygen/main.hpp @@ -0,0 +1,3 @@ +#pragma once + +std::string get_pid(); diff --git a/Rx/v2/examples/doxygen/merge.cpp b/Rx/v2/examples/doxygen/merge.cpp index 6ff6539..008c378 100644 --- a/Rx/v2/examples/doxygen/merge.cpp +++ b/Rx/v2/examples/doxygen/merge.cpp @@ -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"); diff --git a/Rx/v2/examples/doxygen/merge_delay_error.cpp b/Rx/v2/examples/doxygen/merge_delay_error.cpp index 8c28cd8..ae75926 100644 --- a/Rx/v2/examples/doxygen/merge_delay_error.cpp +++ b/Rx/v2/examples/doxygen/merge_delay_error.cpp @@ -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;}); @@ -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; }); @@ -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; }); @@ -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()); diff --git a/Rx/v2/examples/doxygen/observe_on.cpp b/Rx/v2/examples/doxygen/observe_on.cpp index 927c339..9046999 100644 --- a/Rx/v2/examples/doxygen/observe_on.cpp +++ b/Rx/v2/examples/doxygen/observe_on.cpp @@ -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"); diff --git a/Rx/v2/examples/doxygen/pairwise.cpp b/Rx/v2/examples/doxygen/pairwise.cpp index 3dd8d34..3133679 100644 --- a/Rx/v2/examples/doxygen/pairwise.cpp +++ b/Rx/v2/examples/doxygen/pairwise.cpp @@ -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"); diff --git a/Rx/v2/examples/doxygen/range.cpp b/Rx/v2/examples/doxygen/range.cpp index 69eecbd..3abb0ec 100644 --- a/Rx/v2/examples/doxygen/range.cpp +++ b/Rx/v2/examples/doxygen/range.cpp @@ -13,7 +13,7 @@ SCENARIO("range sample"){ printf("//! [range sample]\n"); } -std::string get_pid(); +#include "main.hpp" SCENARIO("threaded range sample"){ printf("//! [threaded range sample]\n"); diff --git a/Rx/v2/examples/doxygen/replay.cpp b/Rx/v2/examples/doxygen/replay.cpp index d6f08ed..2340851 100644 --- a/Rx/v2/examples/doxygen/replay.cpp +++ b/Rx/v2/examples/doxygen/replay.cpp @@ -3,7 +3,7 @@ #include "rxcpp/rx-test.hpp" #include "catch.hpp" -std::string get_pid(); +#include "main.hpp" SCENARIO("replay sample"){ printf("//! [replay sample]\n"); diff --git a/Rx/v2/examples/doxygen/skip_until.cpp b/Rx/v2/examples/doxygen/skip_until.cpp index c539d8e..d99cb6e 100644 --- a/Rx/v2/examples/doxygen/skip_until.cpp +++ b/Rx/v2/examples/doxygen/skip_until.cpp @@ -15,7 +15,7 @@ SCENARIO("skip_until sample"){ printf("//! [skip_until sample]\n"); } -std::string get_pid(); +#include "main.hpp" SCENARIO("threaded skip_until sample"){ printf("//! [threaded skip_until sample]\n"); diff --git a/Rx/v2/examples/doxygen/subscribe_on.cpp b/Rx/v2/examples/doxygen/subscribe_on.cpp index e2614bc..7a9da50 100644 --- a/Rx/v2/examples/doxygen/subscribe_on.cpp +++ b/Rx/v2/examples/doxygen/subscribe_on.cpp @@ -3,7 +3,7 @@ #include "rxcpp/rx-test.hpp" #include "catch.hpp" -std::string get_pid(); +#include "main.hpp" SCENARIO("subscribe_on sample"){ printf("//! [subscribe_on sample]\n"); diff --git a/Rx/v2/examples/doxygen/take_until.cpp b/Rx/v2/examples/doxygen/take_until.cpp index 5c98bc4..082171b 100644 --- a/Rx/v2/examples/doxygen/take_until.cpp +++ b/Rx/v2/examples/doxygen/take_until.cpp @@ -26,7 +26,7 @@ SCENARIO("take_until time sample"){ printf("//! [take_until time sample]\n"); } -std::string get_pid(); +#include "main.hpp" SCENARIO("threaded take_until sample"){ printf("//! [threaded take_until sample]\n"); diff --git a/Rx/v2/examples/doxygen/with_latest_from.cpp b/Rx/v2/examples/doxygen/with_latest_from.cpp index 200f446..cf0a422 100644 --- a/Rx/v2/examples/doxygen/with_latest_from.cpp +++ b/Rx/v2/examples/doxygen/with_latest_from.cpp @@ -17,7 +17,7 @@ SCENARIO("with_latest_from sample"){ printf("//! [with_latest_from sample]\n"); } -std::string get_pid(); +#include "main.hpp" SCENARIO("Coordination with_latest_from sample"){ printf("//! [Coordination with_latest_from sample]\n"); diff --git a/Rx/v2/examples/doxygen/zip.cpp b/Rx/v2/examples/doxygen/zip.cpp index c5cd07b..6bd295b 100644 --- a/Rx/v2/examples/doxygen/zip.cpp +++ b/Rx/v2/examples/doxygen/zip.cpp @@ -17,7 +17,7 @@ SCENARIO("zip sample"){ printf("//! [zip sample]\n"); } -std::string get_pid(); +#include "main.hpp" SCENARIO("Coordination zip sample"){ printf("//! [Coordination zip sample]\n"); diff --git a/Rx/v2/src/rxcpp/rx-includes.hpp b/Rx/v2/src/rxcpp/rx-includes.hpp index 1f5c5e4..1eb47db 100644 --- a/Rx/v2/src/rxcpp/rx-includes.hpp +++ b/Rx/v2/src/rxcpp/rx-includes.hpp @@ -27,6 +27,8 @@ #define RXCPP_USE_EXCEPTIONS 1 #endif +#define RXCPP_NORETURN __declspec(noreturn) + #elif defined(__clang__) #if __has_feature(cxx_rvalue_references) @@ -42,6 +44,12 @@ #define RXCPP_USE_EXCEPTIONS 1 #endif +#if __has_feature(cxx_attributes) +#define RXCPP_NORETURN [[noreturn]] +#else +#define RXCPP_NORETURN __attribute__ ((noreturn)) +#endif + #elif defined(__GNUG__) #define GCC_VERSION (__GNUC__ * 10000 + \ @@ -64,6 +72,8 @@ #define RXCPP_USE_EXCEPTIONS 1 #endif +#define RXCPP_NORETURN __attribute__ ((noreturn)) + #endif // diff --git a/Rx/v2/src/rxcpp/rx-subscription.hpp b/Rx/v2/src/rxcpp/rx-subscription.hpp index ee4e53e..2d6bcb6 100644 --- a/Rx/v2/src/rxcpp/rx-subscription.hpp +++ b/Rx/v2/src/rxcpp/rx-subscription.hpp @@ -117,6 +117,14 @@ private: std::terminate(); } } + + explicit subscription(std::shared_ptr<base_subscription_state> s) + : state(std::move(s)) + { + if (!state) { + std::terminate(); + } + } public: subscription() @@ -178,9 +186,23 @@ public: weak_state_type get_weak() { return state; } + + // Atomically promote weak subscription to strong. + // Calls std::terminate if w has already expired. static subscription lock(weak_state_type w) { return subscription(w); } + + // Atomically try to promote weak subscription to strong. + // Returns an empty maybe<> if w has already expired. + static rxu::maybe<subscription> maybe_lock(weak_state_type w) { + auto strong_subscription = w.lock(); + if (!strong_subscription) { + return rxu::detail::maybe<subscription>{}; + } else { + return rxu::detail::maybe<subscription>{subscription{std::move(strong_subscription)}}; + } + } }; inline bool operator<(const subscription& lhs, const subscription& rhs) { @@ -223,8 +245,14 @@ private: typedef subscription::weak_state_type weak_subscription; struct composite_subscription_state : public std::enable_shared_from_this<composite_subscription_state> { + // invariant: cannot access this data without the lock held. std::set<subscription> subscriptions; + // double checked locking: + // issubscribed must be loaded again after each lock acquisition. + // invariant: + // never call subscription::unsubscribe with lock held. std::mutex lock; + // invariant: transitions from 'true' to 'false' exactly once, at any time. std::atomic<bool> issubscribed; ~composite_subscription_state() @@ -242,29 +270,78 @@ private: { } + // Atomically add 's' to the set of subscriptions. + // + // If unsubscribe() has already occurred, this immediately + // calls s.unsubscribe(). + // + // cs.unsubscribe() [must] happens-before s.unsubscribe() + // + // Due to the un-atomic nature of calling 's.unsubscribe()', + // it is possible to observe the unintuitive + // add(s)=>s.unsubscribe() prior + // to any of the unsubscribe()=>sN.unsubscribe(). inline weak_subscription add(subscription s) { - if (!issubscribed) { + if (!issubscribed) { // load.acq [seq_cst] s.unsubscribe(); } else if (s.is_subscribed()) { std::unique_lock<decltype(lock)> guard(lock); - subscriptions.insert(s); + if (!issubscribed) { // load.acq [seq_cst] + // unsubscribe was called concurrently. + guard.unlock(); + // invariant: do not call unsubscribe with lock held. + s.unsubscribe(); + } else { + subscriptions.insert(s); + } } return s.get_weak(); } + // Atomically remove 'w' from the set of subscriptions. + // + // This does nothing if 'w' was already previously removed, + // or refers to an expired value. inline void remove(weak_subscription w) { - if (issubscribed && !w.expired()) { - auto s = subscription::lock(w); + if (issubscribed) { // load.acq [seq_cst] + rxu::maybe<subscription> maybe_subscription = subscription::maybe_lock(w); + + if (maybe_subscription.empty()) { + // Do nothing if the subscription has already expired. + return; + } + std::unique_lock<decltype(lock)> guard(lock); - subscriptions.erase(std::move(s)); + // invariant: subscriptions must be accessed under the lock. + + if (issubscribed) { // load.acq [seq_cst] + subscription& s = maybe_subscription.get(); + subscriptions.erase(std::move(s)); + } // else unsubscribe() was called concurrently; this becomes a no-op. } } + // Atomically clear all subscriptions that were observably added + // (and not subsequently observably removed). + // + // Un-atomically call unsubscribe on those subscriptions. + // + // forall subscriptions in {add(s1),add(s2),...} + // - {remove(s3), remove(s4), ...}: + // cs.unsubscribe() || cs.clear() happens before s.unsubscribe() + // + // cs.unsubscribe() observed-before cs.clear ==> do nothing. inline void clear() { - if (issubscribed) { + if (issubscribed) { // load.acq [seq_cst] std::unique_lock<decltype(lock)> guard(lock); + if (!issubscribed) { // load.acq [seq_cst] + // unsubscribe was called concurrently. + return; + } + std::set<subscription> v(std::move(subscriptions)); + // invariant: do not call unsubscribe with lock held. guard.unlock(); std::for_each(v.begin(), v.end(), [](const subscription& s) { @@ -272,11 +349,29 @@ private: } } + // Atomically clear all subscriptions that were observably added + // (and not subsequently observably removed). + // + // Un-atomically call unsubscribe on those subscriptions. + // + // Switches to an 'unsubscribed' state, all subsequent + // adds are immediately unsubscribed. + // + // cs.unsubscribe() [must] happens-before + // cs.add(s) ==> s.unsubscribe() + // + // forall subscriptions in {add(s1),add(s2),...} + // - {remove(s3), remove(s4), ...}: + // cs.unsubscribe() || cs.clear() happens before s.unsubscribe() inline void unsubscribe() { - if (issubscribed.exchange(false)) { + if (issubscribed.exchange(false)) { // cas.acq_rel [seq_cst] std::unique_lock<decltype(lock)> guard(lock); + // is_subscribed can only transition to 'false' once, + // does not need an extra atomic access here. + std::set<subscription> v(std::move(subscriptions)); + // invariant: do not call unsubscribe with lock held. guard.unlock(); std::for_each(v.begin(), v.end(), [](const subscription& s) { diff --git a/Rx/v2/src/rxcpp/rx-util.hpp b/Rx/v2/src/rxcpp/rx-util.hpp index 9ce455f..e5867e5 100644 --- a/Rx/v2/src/rxcpp/rx-util.hpp +++ b/Rx/v2/src/rxcpp/rx-util.hpp @@ -899,7 +899,7 @@ error_ptr make_error_ptr(E&& e) { } // Replace std::rethrow_exception to be compatible with our error_ptr typedef. -[[noreturn]] inline void rethrow_exception(error_ptr e) { +RXCPP_NORETURN inline void rethrow_exception(error_ptr e) { #if RXCPP_USE_EXCEPTIONS std::rethrow_exception(e); #else @@ -917,7 +917,7 @@ error_ptr make_error_ptr(E&& e) { // A replacement for the "throw" keyword which is illegal when // exceptions are disabled with -fno-exceptions. template <typename E> -[[noreturn]] inline void throw_exception(E&& e) { +RXCPP_NORETURN inline void throw_exception(E&& e) { #if RXCPP_USE_EXCEPTIONS throw std::forward<E>(e); #else @@ -930,7 +930,7 @@ template <typename E> // TODO: Do we really need this? rxu::rethrow_exception(rxu::current_exception()) // would have the same semantics in either case. -[[noreturn]] inline void rethrow_current_exception() { +RXCPP_NORETURN inline void rethrow_current_exception() { #if RXCPP_USE_EXCEPTIONS std::rethrow_exception(std::current_exception()); #else diff --git a/Rx/v2/src/rxcpp/schedulers/rx-newthread.hpp b/Rx/v2/src/rxcpp/schedulers/rx-newthread.hpp index e31ed55..5145e92 100644 --- a/Rx/v2/src/rxcpp/schedulers/rx-newthread.hpp +++ b/Rx/v2/src/rxcpp/schedulers/rx-newthread.hpp @@ -72,6 +72,7 @@ private: state->lifetime.add([keepAlive](){ std::unique_lock<std::mutex> guard(keepAlive->lock); auto expired = std::move(keepAlive->q); + keepAlive->q = new_worker_state::queue_item_time{}; if (!keepAlive->q.empty()) std::terminate(); keepAlive->wake.notify_one(); diff --git a/Rx/v2/src/rxcpp/subjects/rx-replaysubject.hpp b/Rx/v2/src/rxcpp/subjects/rx-replaysubject.hpp index b7f7d68..020b0f8 100644 --- a/Rx/v2/src/rxcpp/subjects/rx-replaysubject.hpp +++ b/Rx/v2/src/rxcpp/subjects/rx-replaysubject.hpp @@ -43,6 +43,7 @@ class replay_observer : public detail::multicast_observer<T> mutable std::list<time_point_type> time_points; mutable count_type count; mutable period_type period; + mutable composite_subscription replayLifetime; public: mutable coordination_type coordination; mutable coordinator_type coordinator; @@ -56,9 +57,13 @@ class replay_observer : public detail::multicast_observer<T> } public: - explicit replay_observer_state(count_type _count, period_type _period, coordination_type _coordination, coordinator_type _coordinator) + ~replay_observer_state(){ + replayLifetime.unsubscribe(); + } + explicit replay_observer_state(count_type _count, period_type _period, coordination_type _coordination, coordinator_type _coordinator, composite_subscription _replayLifetime) : count(_count) , period(_period) + , replayLifetime(_replayLifetime) , coordination(std::move(_coordination)) , coordinator(std::move(_coordinator)) { @@ -66,6 +71,7 @@ class replay_observer : public detail::multicast_observer<T> void add(T v) const { std::unique_lock<std::mutex> guard(lock); + if (!count.empty()) { if (values.size() == count.get()) remove_oldest(); @@ -89,11 +95,12 @@ class replay_observer : public detail::multicast_observer<T> std::shared_ptr<replay_observer_state> state; public: - replay_observer(count_type count, period_type period, coordination_type coordination, composite_subscription cs) - : base_type(cs) + replay_observer(count_type count, period_type period, coordination_type coordination, composite_subscription replayLifetime, composite_subscription subscriberLifetime) + : base_type(subscriberLifetime) { - auto coordinator = coordination.create_coordinator(cs); - state = std::make_shared<replay_observer_state>(std::move(count), std::move(period), std::move(coordination), std::move(coordinator)); + replayLifetime.add(subscriberLifetime); + auto coordinator = coordination.create_coordinator(replayLifetime); + state = std::make_shared<replay_observer_state>(std::move(count), std::move(period), std::move(coordination), std::move(coordinator), std::move(replayLifetime)); } subscriber<T> get_subscriber() const { @@ -129,22 +136,22 @@ class replay public: explicit replay(Coordination cn, composite_subscription cs = composite_subscription()) - : s(count_type(), period_type(), cn, cs) + : s(count_type(), period_type(), cn, cs, composite_subscription{}) { } replay(std::size_t count, Coordination cn, composite_subscription cs = composite_subscription()) - : s(count_type(std::move(count)), period_type(), cn, cs) + : s(count_type(std::move(count)), period_type(), cn, cs, composite_subscription{}) { } replay(rxsc::scheduler::clock_type::duration period, Coordination cn, composite_subscription cs = composite_subscription()) - : s(count_type(), period_type(period), cn, cs) + : s(count_type(), period_type(period), cn, cs, composite_subscription{}) { } replay(std::size_t count, rxsc::scheduler::clock_type::duration period, Coordination cn, composite_subscription cs = composite_subscription()) - : s(count_type(count), period_type(period), cn, cs) + : s(count_type(count), period_type(period), cn, cs, composite_subscription{}) { } @@ -163,9 +170,8 @@ public: observable<T> get_observable() const { auto keepAlive = s; auto observable = make_observable_dynamic<T>([=](subscriber<T> o){ - if (keepAlive.get_subscription().is_subscribed()) { - for (auto&& value: get_values()) - o.on_next(value); + for (auto&& value: get_values()) { + o.on_next(value); } keepAlive.add(keepAlive.get_subscriber(), std::move(o)); }); diff --git a/Rx/v2/test/CMakeLists.txt b/Rx/v2/test/CMakeLists.txt index dcb998f..c2d1530 100644 --- a/Rx/v2/test/CMakeLists.txt +++ b/Rx/v2/test/CMakeLists.txt @@ -88,6 +88,15 @@ set(TEST_SOURCES ${TEST_DIR}/operators/zip.cpp ) +set(TEST_COMPILE_DEFINITIONS "") +set(TEST_COMMAND_ARGUMENTS "") + +if (NOT RX_USE_EXCEPTIONS) + MESSAGE( STATUS "no exceptions" ) + list(APPEND TEST_COMPILE_DEFINITIONS CATCH_CONFIG_DISABLE_EXCEPTIONS) + list(APPEND TEST_COMMAND_ARGUMENTS -e) +endif() + add_executable(rxcppv2_test ${TEST_DIR}/test.cpp ${TEST_SOURCES}) add_executable(rxcpp::tests ALIAS rxcppv2_test) @@ -98,6 +107,7 @@ set_target_properties( ) target_compile_options(rxcppv2_test PUBLIC ${RX_COMPILE_OPTIONS}) target_compile_features(rxcppv2_test PUBLIC ${RX_COMPILE_FEATURES}) +target_compile_definitions(rxcppv2_test PUBLIC ${TEST_COMPILE_DEFINITIONS}) target_include_directories(rxcppv2_test PUBLIC ${RX_SRC_DIR} ${RX_CATCH_DIR} ) @@ -110,7 +120,7 @@ foreach(ONE_TEST_SOURCE ${TEST_SOURCES}) set(ONE_TEST_FULL_NAME "rxcpp_test_${ONE_TEST_NAME}") add_executable( ${ONE_TEST_FULL_NAME} ${ONE_TEST_SOURCE} ) add_executable( rxcpp::${ONE_TEST_NAME} ALIAS ${ONE_TEST_FULL_NAME}) - target_compile_definitions(${ONE_TEST_FULL_NAME} PUBLIC "CATCH_CONFIG_MAIN") + target_compile_definitions(${ONE_TEST_FULL_NAME} PUBLIC "CATCH_CONFIG_MAIN" ${TEST_COMPILE_DEFINITIONS}) target_compile_options(${ONE_TEST_FULL_NAME} PUBLIC ${RX_COMPILE_OPTIONS}) target_compile_features(${ONE_TEST_FULL_NAME} PUBLIC ${RX_COMPILE_FEATURES}) target_include_directories(${ONE_TEST_FULL_NAME} @@ -118,7 +128,7 @@ foreach(ONE_TEST_SOURCE ${TEST_SOURCES}) ) target_link_libraries(${ONE_TEST_FULL_NAME} ${CMAKE_THREAD_LIBS_INIT}) - add_test(NAME ${ONE_TEST_NAME} COMMAND ${ONE_TEST_FULL_NAME}) + add_test(NAME ${ONE_TEST_NAME} COMMAND ${ONE_TEST_FULL_NAME} ${TEST_COMMAND_ARGUMENTS}) endforeach(ONE_TEST_SOURCE ${TEST_SOURCES}) diff --git a/Rx/v2/test/operators/buffer.cpp b/Rx/v2/test/operators/buffer.cpp index 2aec5d1..e1b980c 100644 --- a/Rx/v2/test/operators/buffer.cpp +++ b/Rx/v2/test/operators/buffer.cpp @@ -455,7 +455,7 @@ SCENARIO("buffer count error 2", "[buffer][operators]"){ } } -SCENARIO("buffer with time on intervals", "[buffer_with_time][operators][long][hide]"){ +SCENARIO("buffer with time on intervals", "[buffer_with_time][operators][long][!hide]"){ GIVEN("7 intervals of 2 seconds"){ WHEN("the period is 2sec and the initial is 5sec"){ // time: |-----------------| @@ -500,7 +500,7 @@ SCENARIO("buffer with time on intervals", "[buffer_with_time][operators][long][h } } -SCENARIO("buffer with time on intervals, implicit coordination", "[buffer_with_time][operators][long][hide]"){ +SCENARIO("buffer with time on intervals, implicit coordination", "[buffer_with_time][operators][long][!hide]"){ GIVEN("7 intervals of 2 seconds"){ WHEN("the period is 2sec and the initial is 5sec"){ // time: |-----------------| @@ -543,7 +543,7 @@ SCENARIO("buffer with time on intervals, implicit coordination", "[buffer_with_t } } -SCENARIO("buffer with time on overlapping intervals", "[buffer_with_time][operators][long][hide]"){ +SCENARIO("buffer with time on overlapping intervals", "[buffer_with_time][operators][long][!hide]"){ GIVEN("5 intervals of 2 seconds"){ WHEN("the period is 2sec and the initial is 5sec"){ // time: |-------------| @@ -587,7 +587,7 @@ SCENARIO("buffer with time on overlapping intervals", "[buffer_with_time][operat } } -SCENARIO("buffer with time on overlapping intervals, implicit coordination", "[buffer_with_time][operators][long][hide]"){ +SCENARIO("buffer with time on overlapping intervals, implicit coordination", "[buffer_with_time][operators][long][!hide]"){ GIVEN("5 intervals of 2 seconds"){ WHEN("the period is 2sec and the initial is 5sec"){ // time: |-------------| @@ -631,7 +631,7 @@ SCENARIO("buffer with time on overlapping intervals, implicit coordination", "[b } } -SCENARIO("buffer with time on intervals, error", "[buffer_with_time][operators][long][hide]"){ +SCENARIO("buffer with time on intervals, error", "[buffer_with_time][operators][long][!hide]"){ GIVEN("5 intervals of 2 seconds"){ WHEN("the period is 2sec and the initial is 5sec"){ // time: |-------------| diff --git a/Rx/v2/test/operators/concat.cpp b/Rx/v2/test/operators/concat.cpp index 86f4a7e..88dcac7 100644 --- a/Rx/v2/test/operators/concat.cpp +++ b/Rx/v2/test/operators/concat.cpp @@ -5,7 +5,7 @@ const int static_onnextcalls = 1000000; -SCENARIO("synchronize concat ranges", "[hide][range][synchronize][concat][perf]"){ +SCENARIO("synchronize concat ranges", "[!hide][range][synchronize][concat][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("some ranges"){ WHEN("generating ints"){ @@ -33,7 +33,7 @@ SCENARIO("synchronize concat ranges", "[hide][range][synchronize][concat][perf]" } } -SCENARIO("observe_on concat ranges", "[hide][range][observe_on][concat][perf]"){ +SCENARIO("observe_on concat ranges", "[!hide][range][observe_on][concat][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("some ranges"){ WHEN("generating ints"){ @@ -61,7 +61,7 @@ SCENARIO("observe_on concat ranges", "[hide][range][observe_on][concat][perf]"){ } } -SCENARIO("serialize concat ranges", "[hide][range][serialize][concat][perf]"){ +SCENARIO("serialize concat ranges", "[!hide][range][serialize][concat][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("some ranges"){ WHEN("generating ints"){ diff --git a/Rx/v2/test/operators/concat_map.cpp b/Rx/v2/test/operators/concat_map.cpp index cc163b1..cfd6f4f 100644 --- a/Rx/v2/test/operators/concat_map.cpp +++ b/Rx/v2/test/operators/concat_map.cpp @@ -8,7 +8,7 @@ static const int static_tripletCount = 100; -SCENARIO("concat_transform pythagorian ranges", "[hide][range][concat_transform][pythagorian][perf]"){ +SCENARIO("concat_transform pythagorian ranges", "[!hide][range][concat_transform][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ @@ -53,7 +53,7 @@ SCENARIO("concat_transform pythagorian ranges", "[hide][range][concat_transform] } } -SCENARIO("synchronize concat_transform pythagorian ranges", "[hide][range][concat_transform][synchronize][pythagorian][perf]"){ +SCENARIO("synchronize concat_transform pythagorian ranges", "[!hide][range][concat_transform][synchronize][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ @@ -101,7 +101,7 @@ SCENARIO("synchronize concat_transform pythagorian ranges", "[hide][range][conca } } -SCENARIO("observe_on concat_transform pythagorian ranges", "[hide][range][concat_transform][observe_on][pythagorian][perf]"){ +SCENARIO("observe_on concat_transform pythagorian ranges", "[!hide][range][concat_transform][observe_on][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ @@ -150,7 +150,7 @@ SCENARIO("observe_on concat_transform pythagorian ranges", "[hide][range][concat } } -SCENARIO("serialize concat_transform pythagorian ranges", "[hide][range][concat_transform][serialize][pythagorian][perf]"){ +SCENARIO("serialize concat_transform pythagorian ranges", "[!hide][range][concat_transform][serialize][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ diff --git a/Rx/v2/test/operators/flat_map.cpp b/Rx/v2/test/operators/flat_map.cpp index 2e01a30..e1837b0 100644 --- a/Rx/v2/test/operators/flat_map.cpp +++ b/Rx/v2/test/operators/flat_map.cpp @@ -8,7 +8,7 @@ static const int static_tripletCount = 100; -SCENARIO("pythagorian for loops", "[hide][for][pythagorian][perf]"){ +SCENARIO("pythagorian for loops", "[!hide][for][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("a for loop"){ WHEN("generating pythagorian triplets"){ @@ -45,7 +45,7 @@ SCENARIO("pythagorian for loops", "[hide][for][pythagorian][perf]"){ } } -SCENARIO("merge_transform pythagorian ranges", "[hide][range][merge_transform][pythagorian][perf]"){ +SCENARIO("merge_transform pythagorian ranges", "[!hide][range][merge_transform][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ @@ -89,7 +89,7 @@ SCENARIO("merge_transform pythagorian ranges", "[hide][range][merge_transform][p } } -SCENARIO("synchronize merge_transform pythagorian ranges", "[hide][range][merge_transform][synchronize][pythagorian][perf]"){ +SCENARIO("synchronize merge_transform pythagorian ranges", "[!hide][range][merge_transform][synchronize][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ @@ -137,7 +137,7 @@ SCENARIO("synchronize merge_transform pythagorian ranges", "[hide][range][merge_ } } -SCENARIO("observe_on merge_transform pythagorian ranges", "[hide][range][merge_transform][observe_on][pythagorian][perf]"){ +SCENARIO("observe_on merge_transform pythagorian ranges", "[!hide][range][merge_transform][observe_on][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ @@ -185,7 +185,7 @@ SCENARIO("observe_on merge_transform pythagorian ranges", "[hide][range][merge_t } } -SCENARIO("serialize merge_transform pythagorian ranges", "[hide][range][merge_transform][serialize][pythagorian][perf]"){ +SCENARIO("serialize merge_transform pythagorian ranges", "[!hide][range][merge_transform][serialize][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ diff --git a/Rx/v2/test/operators/group_by.cpp b/Rx/v2/test/operators/group_by.cpp index b575cd9..645bda4 100644 --- a/Rx/v2/test/operators/group_by.cpp +++ b/Rx/v2/test/operators/group_by.cpp @@ -11,7 +11,7 @@ #include <locale> #include <sstream> -SCENARIO("range partitioned by group_by across hardware threads to derive pi", "[hide][pi][group_by][observe_on][long][perf]"){ +SCENARIO("range partitioned by group_by across hardware threads to derive pi", "[!hide][pi][group_by][observe_on][long][perf]"){ GIVEN("a for loop"){ WHEN("partitioning pi series across all hardware threads"){ @@ -93,7 +93,7 @@ SCENARIO("range partitioned by group_by across hardware threads to derive pi", " } } -SCENARIO("range partitioned by dividing work across hardware threads to derive pi", "[hide][pi][observe_on][long][perf]"){ +SCENARIO("range partitioned by dividing work across hardware threads to derive pi", "[!hide][pi][observe_on][long][perf]"){ GIVEN("a for loop"){ WHEN("partitioning pi series across all hardware threads"){ diff --git a/Rx/v2/test/operators/merge.cpp b/Rx/v2/test/operators/merge.cpp index 9a7f28c..917d74d 100644 --- a/Rx/v2/test/operators/merge.cpp +++ b/Rx/v2/test/operators/merge.cpp @@ -6,7 +6,7 @@ const int static_onnextcalls = 1000000; -SCENARIO("synchronize merge ranges", "[hide][range][synchronize][merge][perf]"){ +SCENARIO("synchronize merge ranges", "[!hide][range][synchronize][merge][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("some ranges"){ WHEN("generating ints"){ @@ -34,7 +34,7 @@ SCENARIO("synchronize merge ranges", "[hide][range][synchronize][merge][perf]"){ } } -SCENARIO("observe_on merge ranges", "[hide][range][observe_on][merge][perf]"){ +SCENARIO("observe_on merge ranges", "[!hide][range][observe_on][merge][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("some ranges"){ WHEN("generating ints"){ @@ -62,7 +62,7 @@ SCENARIO("observe_on merge ranges", "[hide][range][observe_on][merge][perf]"){ } } -SCENARIO("serialize merge ranges", "[hide][range][serialize][merge][perf]"){ +SCENARIO("serialize merge ranges", "[!hide][range][serialize][merge][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("some ranges"){ WHEN("generating ints"){ diff --git a/Rx/v2/test/operators/merge_delay_error.cpp b/Rx/v2/test/operators/merge_delay_error.cpp index b53b884..83172ec 100644 --- a/Rx/v2/test/operators/merge_delay_error.cpp +++ b/Rx/v2/test/operators/merge_delay_error.cpp @@ -3,8 +3,6 @@ #include <rxcpp/operators/rx-merge_delay_error.hpp> #include <rxcpp/operators/rx-observe_on.hpp> -const int static_onnextcalls = 1000000; - //merge_delay_error must work the very same way as `merge()` except the error handling SCENARIO("merge_delay_error completes", "[merge][join][operators]"){ diff --git a/Rx/v2/test/operators/observe_on.cpp b/Rx/v2/test/operators/observe_on.cpp index ffa85aa..aac2d40 100644 --- a/Rx/v2/test/operators/observe_on.cpp +++ b/Rx/v2/test/operators/observe_on.cpp @@ -5,7 +5,7 @@ const int static_onnextcalls = 100000; -SCENARIO("range observed on new_thread", "[hide][range][observe_on_debug][observe_on][long][perf]"){ +SCENARIO("range observed on new_thread", "[!hide][range][observe_on_debug][observe_on][long][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("a range"){ WHEN("multicasting a million ints"){ diff --git a/Rx/v2/test/operators/publish.cpp b/Rx/v2/test/operators/publish.cpp index 87c8fff..c977597 100644 --- a/Rx/v2/test/operators/publish.cpp +++ b/Rx/v2/test/operators/publish.cpp @@ -4,7 +4,7 @@ #include <rxcpp/operators/rx-ref_count.hpp> -SCENARIO("publish range", "[hide][range][subject][publish][subject][operators]"){ +SCENARIO("publish range", "[!hide][range][subject][publish][subject][operators]"){ GIVEN("a range"){ WHEN("published"){ auto published = rxs::range<int>(0, 10).publish(); diff --git a/Rx/v2/test/operators/scan.cpp b/Rx/v2/test/operators/scan.cpp index f1d64e9..1cb38a5 100644 --- a/Rx/v2/test/operators/scan.cpp +++ b/Rx/v2/test/operators/scan.cpp @@ -3,7 +3,7 @@ #include <rxcpp/operators/rx-take.hpp> #include <rxcpp/operators/rx-scan.hpp> -SCENARIO("scan: issue 41", "[scan][operators][issue][hide]"){ +SCENARIO("scan: issue 41", "[scan][operators][issue][!hide]"){ GIVEN("map of scan of interval"){ auto sc = rxsc::make_current_thread(); auto so = rxcpp::synchronize_in_one_worker(sc); diff --git a/Rx/v2/test/operators/subscribe_on.cpp b/Rx/v2/test/operators/subscribe_on.cpp index 936fbc1..ef8a8c7 100644 --- a/Rx/v2/test/operators/subscribe_on.cpp +++ b/Rx/v2/test/operators/subscribe_on.cpp @@ -8,7 +8,7 @@ static const int static_subscriptions = 50000; -SCENARIO("for loop subscribes to map with subscribe_on and observe_on", "[hide][for][just][subscribe][subscribe_on][observe_on][long][perf]"){ +SCENARIO("for loop subscribes to map with subscribe_on and observe_on", "[!hide][for][just][subscribe][subscribe_on][observe_on][long][perf]"){ const int& subscriptions = static_subscriptions; GIVEN("a for loop"){ WHEN("subscribe 50K times"){ @@ -48,7 +48,7 @@ SCENARIO("for loop subscribes to map with subscribe_on and observe_on", "[hide][ } } -SCENARIO("for loop subscribes to map with subscribe_on", "[hide][subscribe_on_only][for][just][subscribe][subscribe_on][long][perf]"){ +SCENARIO("for loop subscribes to map with subscribe_on", "[!hide][subscribe_on_only][for][just][subscribe][subscribe_on][long][perf]"){ const int& subscriptions = static_subscriptions; GIVEN("a for loop"){ WHEN("subscribe 50K times"){ diff --git a/Rx/v2/test/sources/interval.cpp b/Rx/v2/test/sources/interval.cpp index 4a7c8dc..9ab2fca 100644 --- a/Rx/v2/test/sources/interval.cpp +++ b/Rx/v2/test/sources/interval.cpp @@ -1,6 +1,6 @@ #include "../test.h" -SCENARIO("schedule_periodically", "[hide][periodically][scheduler][long][perf][sources]"){ +SCENARIO("schedule_periodically", "[!hide][periodically][scheduler][long][perf][sources]"){ GIVEN("schedule_periodically"){ WHEN("the period is 1sec and the initial is 2sec"){ using namespace std::chrono; @@ -21,7 +21,7 @@ SCENARIO("schedule_periodically", "[hide][periodically][scheduler][long][perf][s } } -SCENARIO("schedule_periodically by duration", "[hide][periodically][scheduler][long][perf][sources]"){ +SCENARIO("schedule_periodically by duration", "[!hide][periodically][scheduler][long][perf][sources]"){ GIVEN("schedule_periodically_duration"){ WHEN("the period is 1sec and the initial is 2sec"){ using namespace std::chrono; @@ -64,7 +64,7 @@ SCENARIO("schedule_periodically by duration", "[hide][periodically][scheduler][l } } -SCENARIO("intervals", "[hide][periodically][interval][scheduler][long][perf][sources]"){ +SCENARIO("intervals", "[!hide][periodically][interval][scheduler][long][perf][sources]"){ GIVEN("10 intervals of 1 seconds"){ WHEN("the period is 1sec and the initial is 2sec"){ using namespace std::chrono; diff --git a/Rx/v2/test/sources/timer.cpp b/Rx/v2/test/sources/timer.cpp index 4f62b10..3f46b21 100644 --- a/Rx/v2/test/sources/timer.cpp +++ b/Rx/v2/test/sources/timer.cpp @@ -1,6 +1,6 @@ #include "../test.h" -SCENARIO("timer", "[hide][periodically][timer][scheduler][long][perf][sources]"){ +SCENARIO("timer", "[!hide][periodically][timer][scheduler][long][perf][sources]"){ GIVEN("the timer of 1 sec"){ WHEN("the period is 1 sec"){ using namespace std::chrono; diff --git a/Rx/v2/test/subjects/subject.cpp b/Rx/v2/test/subjects/subject.cpp index 9e21614..09318a3 100644 --- a/Rx/v2/test/subjects/subject.cpp +++ b/Rx/v2/test/subjects/subject.cpp @@ -10,7 +10,7 @@ const int static_onnextcalls = 10000000; static int aliased = 0; -SCENARIO("for loop locks mutex", "[hide][for][mutex][long][perf]"){ +SCENARIO("for loop locks mutex", "[!hide][for][mutex][long][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("a for loop"){ WHEN("locking mutex 100 million times"){ @@ -52,7 +52,7 @@ public: } }; } -SCENARIO("for loop calls void on_next(int)", "[hide][for][asyncobserver][baseline][perf]"){ +SCENARIO("for loop calls void on_next(int)", "[!hide][for][asyncobserver][baseline][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("a for loop"){ WHEN("calling on_next 100 million times"){ @@ -137,7 +137,7 @@ public: } }; } -SCENARIO("for loop calls ready on_next(int)", "[hide][for][asyncobserver][ready][perf]"){ +SCENARIO("for loop calls ready on_next(int)", "[!hide][for][asyncobserver][ready][perf]"){ static const int& onnextcalls = static_onnextcalls; GIVEN("a for loop"){ WHEN("calling on_next 100 million times"){ @@ -191,7 +191,7 @@ public: onnext(v); return ready.get_future();} }; } -SCENARIO("for loop calls std::future<unit> on_next(int)", "[hide][for][asyncobserver][future][long][perf]"){ +SCENARIO("for loop calls std::future<unit> on_next(int)", "[!hide][for][asyncobserver][future][long][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("a for loop"){ WHEN("calling on_next 100 million times"){ @@ -218,7 +218,7 @@ SCENARIO("for loop calls std::future<unit> on_next(int)", "[hide][for][asyncobse } } -SCENARIO("for loop calls observer", "[hide][for][observer][perf]"){ +SCENARIO("for loop calls observer", "[!hide][for][observer][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("a for loop"){ WHEN("observing 100 million ints"){ @@ -244,7 +244,7 @@ SCENARIO("for loop calls observer", "[hide][for][observer][perf]"){ } } -SCENARIO("for loop calls subscriber", "[hide][for][subscriber][perf]"){ +SCENARIO("for loop calls subscriber", "[!hide][for][subscriber][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("a for loop"){ WHEN("observing 100 million ints"){ @@ -270,7 +270,7 @@ SCENARIO("for loop calls subscriber", "[hide][for][subscriber][perf]"){ } } -SCENARIO("range calls subscriber", "[hide][range][subscriber][perf]"){ +SCENARIO("range calls subscriber", "[!hide][range][subscriber][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("a range"){ WHEN("observing 100 million ints"){ @@ -296,7 +296,7 @@ SCENARIO("range calls subscriber", "[hide][range][subscriber][perf]"){ } } -SCENARIO("for loop calls subject", "[hide][for][subject][subjects][long][perf]"){ +SCENARIO("for loop calls subject", "[!hide][for][subject][subjects][long][perf]"){ static const int& onnextcalls = static_onnextcalls; GIVEN("a for loop and a subject"){ WHEN("multicasting a million ints"){ @@ -370,7 +370,7 @@ SCENARIO("for loop calls subject", "[hide][for][subject][subjects][long][perf]") } } -SCENARIO("range calls subject", "[hide][range][subject][subjects][long][perf]"){ +SCENARIO("range calls subject", "[!hide][range][subject][subjects][long][perf]"){ static const int& onnextcalls = static_onnextcalls; GIVEN("a range and a subject"){ WHEN("multicasting a million ints"){ diff --git a/Rx/v2/test/subscriptions/subscription.cpp b/Rx/v2/test/subscriptions/subscription.cpp index ab70448..33218a7 100644 --- a/Rx/v2/test/subscriptions/subscription.cpp +++ b/Rx/v2/test/subscriptions/subscription.cpp @@ -8,7 +8,7 @@ #include <sstream> -SCENARIO("observe subscription", "[hide]"){ +SCENARIO("observe subscription", "[!hide]"){ GIVEN("observable of ints"){ WHEN("subscribe"){ auto observers = std::make_shared<std::list<rxcpp::subscriber<int>>>(); @@ -26,7 +26,7 @@ SCENARIO("observe subscription", "[hide]"){ static const int static_subscriptions = 10000; -SCENARIO("for loop subscribes to map", "[hide][for][just][subscribe][long][perf]"){ +SCENARIO("for loop subscribes to map", "[!hide][for][just][subscribe][long][perf]"){ const int& subscriptions = static_subscriptions; GIVEN("a for loop"){ WHEN("subscribe 100K times"){ @@ -71,7 +71,7 @@ SCENARIO("for loop subscribes to map", "[hide][for][just][subscribe][long][perf] } } -SCENARIO("for loop subscribes to combine_latest", "[hide][for][just][combine_latest][subscribe][long][perf]"){ +SCENARIO("for loop subscribes to combine_latest", "[!hide][for][just][combine_latest][subscribe][long][perf]"){ const int& subscriptions = static_subscriptions; GIVEN("a for loop"){ WHEN("subscribe 100K times"){ @@ -109,7 +109,7 @@ SCENARIO("for loop subscribes to combine_latest", "[hide][for][just][combine_lat } } -SCENARIO("synchronized range debug", "[hide][subscribe][range][synchronize_debug][synchronize][long][perf]"){ +SCENARIO("synchronized range debug", "[!hide][subscribe][range][synchronize_debug][synchronize][long][perf]"){ GIVEN("range"){ WHEN("synchronized"){ using namespace std::chrono; @@ -218,7 +218,7 @@ SCENARIO("synchronized range debug", "[hide][subscribe][range][synchronize_debug } } -SCENARIO("observe_on range debug", "[hide][subscribe][range][observe_on_debug][observe_on][long][perf]"){ +SCENARIO("observe_on range debug", "[!hide][subscribe][range][observe_on_debug][observe_on][long][perf]"){ GIVEN("range"){ WHEN("observed on"){ using namespace std::chrono; diff --git a/appveyor.yml b/appveyor.yml index 68ea434..42882b2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,8 +10,6 @@ image: Visual Studio 2017 environment: matrix: - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - VSVER: Visual Studio 12 2013 Win64 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 VSVER: Visual Studio 14 2015 Win64 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 diff --git a/projects/CMake/CMakeLists.txt b/projects/CMake/CMakeLists.txt index 542a91a..3d07447 100644 --- a/projects/CMake/CMakeLists.txt +++ b/projects/CMake/CMakeLists.txt @@ -59,6 +59,7 @@ set(RX_SOURCES ${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-ref_count.hpp ${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-repeat.hpp ${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-replay.hpp + ${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-retry-repeat-common.hpp ${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-retry.hpp ${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-sample_time.hpp ${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-scan.hpp @@ -83,13 +84,16 @@ set(RX_SOURCES ${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-with_latest_from.hpp ${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-window.hpp ${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-window_time.hpp + ${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-window_toggle.hpp ${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-window_time_count.hpp ${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-zip.hpp + ${RXCPP_DIR}/Rx/v2/src/rxcpp/rx-composite_exception.hpp ${RXCPP_DIR}/Rx/v2/src/rxcpp/rx-connectable_observable.hpp ${RXCPP_DIR}/Rx/v2/src/rxcpp/rx-coordination.hpp ${RXCPP_DIR}/Rx/v2/src/rxcpp/rx-coroutine.hpp ${RXCPP_DIR}/Rx/v2/src/rxcpp/rx-grouped_observable.hpp ${RXCPP_DIR}/Rx/v2/src/rxcpp/rx-includes.hpp + ${RXCPP_DIR}/Rx/v2/src/rxcpp/rx-lite.hpp ${RXCPP_DIR}/Rx/v2/src/rxcpp/rx-notification.hpp ${RXCPP_DIR}/Rx/v2/src/rxcpp/rx-observable.hpp ${RXCPP_DIR}/Rx/v2/src/rxcpp/rx-observer.hpp @@ -114,6 +118,7 @@ set(RX_SOURCES ${RXCPP_DIR}/Rx/v2/src/rxcpp/schedulers/rx-virtualtime.hpp ${RXCPP_DIR}/Rx/v2/src/rxcpp/sources/rx-create.hpp ${RXCPP_DIR}/Rx/v2/src/rxcpp/sources/rx-defer.hpp + ${RXCPP_DIR}/Rx/v2/src/rxcpp/sources/rx-empty.hpp ${RXCPP_DIR}/Rx/v2/src/rxcpp/sources/rx-error.hpp ${RXCPP_DIR}/Rx/v2/src/rxcpp/sources/rx-interval.hpp ${RXCPP_DIR}/Rx/v2/src/rxcpp/sources/rx-iterate.hpp @@ -130,8 +135,12 @@ set(RX_SOURCES # Grouping all the source files puts them into a virtual folder in Visual Studio source_group("src" FILES ${RX_SOURCES}) +if (MSVC) +# This 'RxCpp' build target only appears to be a virtual project for IDEs. +# It won't actually build correctly since it is missing the shared.cmake integration. add_library(RxCpp SHARED ${RX_SOURCES}) SET_TARGET_PROPERTIES(RxCpp PROPERTIES LINKER_LANGUAGE CXX) +endif (MSVC) set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE CACHE BOOL "Don't require all projects to be built in order to install" FORCE) diff --git a/projects/CMake/shared.cmake b/projects/CMake/shared.cmake index ac0d09c..f7f7a31 100644 --- a/projects/CMake/shared.cmake +++ b/projects/CMake/shared.cmake @@ -1,5 +1,7 @@ FIND_PACKAGE(Threads) +option(RX_USE_EXCEPTIONS "Use C++ exceptions" ON) + # define some compiler settings MESSAGE( STATUS "CMAKE_CXX_COMPILER_ID: " ${CMAKE_CXX_COMPILER_ID} ) @@ -13,13 +15,21 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") -Wno-error=unused-command-line-argument -ftemplate-depth=1024 ) + if (NOT RX_USE_EXCEPTIONS) + MESSAGE( STATUS "no exceptions" ) + list(APPEND RX_COMPILE_OPTIONS -fno-exceptions) + endif() elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU") MESSAGE( STATUS "gnu compiler version: " ${CMAKE_CXX_COMPILER_VERSION} ) MESSAGE( STATUS "using gnu settings" ) set(RX_COMPILE_OPTIONS -Wall -Wextra -Werror -Wunused ) -elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + if (NOT RX_USE_EXCEPTIONS) + MESSAGE( STATUS "no exceptions" ) + list(APPEND RX_COMPILE_OPTIONS -fno-exceptions) + endif() + elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") MESSAGE( STATUS "msvc compiler version: " ${CMAKE_CXX_COMPILER_VERSION} ) MESSAGE( STATUS "using msvc settings" ) set(RX_COMPILE_OPTIONS @@ -29,9 +39,13 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") /bigobj /DUNICODE /D_UNICODE # it is a new millenium ) + if (NOT RX_USE_EXCEPTIONS) + MESSAGE( STATUS "no exceptions" ) + list(APPEND RX_COMPILE_OPTIONS /EHs-c-) + endif() if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.0.23506.0") - set(RX_COMPILE_OPTIONS - ${RX_COMPILE_OPTIONS} + MESSAGE( STATUS "with coroutines" ) + list(APPEND RX_COMPILE_OPTIONS /await # enable coroutines ) endif() @@ -54,4 +68,4 @@ set(RX_COMPILE_FEATURES set(IX_SRC_DIR ${RXCPP_DIR}/Ix/CPP/src) set(RX_SRC_DIR ${RXCPP_DIR}/Rx/v2/src) -set(RX_CATCH_DIR ${RXCPP_DIR}/ext/catch/include) +set(RX_CATCH_DIR ${RXCPP_DIR}/ext/catch/single_include/catch2) |