Skip to content

replay triggers std::terminate if it uses observe_on_new_thread coordinator and has two subscribers #465

@javaJake

Description

@javaJake

Reproduction:

int main ()
{
    rxcpp::observable<int> data = rxcpp::observable<>::range<int>(1,4);
    rxcpp::connectable_observable<int> dataReplaying = data.replay(rxcpp::observe_on_new_thread());

    dataReplaying.subscribe([](int anInt){
        std::cout << "1: " << anInt << std::endl;
    });

    dataReplaying.subscribe([](int anInt){
        std::cout << "2: " << anInt << std::endl;
    });

    rxcpp::composite_subscription compositeSubscription;
    dataReplaying.connect(compositeSubscription);

    return EXIT_SUCCESS;
}

I expect this code to print as many numbers as it can before the compositeSubscription object destructs and causes all to unsubscribe. Instead, I get a failure on this line:

if (!keepAlive->q.empty()) std::terminate();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions