When using create_worker with a make_new_thread the thread doesn't terminate when the worker goes out of scope. I would assume the thread should terminate when the worker goes out of scope and has no other subscriptions using it, but it seems you are required to call unsubscribe on the worker for the thread to terminate.
Example 1 crashes when its unable to create more threads while Example 2 loops indefinitely.
Is this intended behavior?
Is it possible to create a worker with a thread that is alive until the worker goes out of scope and has no more subscribers?
Example 1
#include "rxcpp/rx.hpp"
#include "rxcpp/rx-scheduler.hpp"
int main()
{
while (true) {
auto sched = rxcpp::schedulers::make_new_thread();
auto worker = sched.create_worker();
}
}
Example 2
#include "rxcpp/rx.hpp"
#include "rxcpp/rx-scheduler.hpp"
int main()
{
while (true) {
auto sched = rxcpp::schedulers::make_new_thread();
auto worker = sched.create_worker();
worker.unsubscribe();
}
}
When using create_worker with a make_new_thread the thread doesn't terminate when the worker goes out of scope. I would assume the thread should terminate when the worker goes out of scope and has no other subscriptions using it, but it seems you are required to call unsubscribe on the worker for the thread to terminate.
Example 1 crashes when its unable to create more threads while Example 2 loops indefinitely. Is this intended behavior?
Is it possible to create a worker with a thread that is alive until the worker goes out of scope and has no more subscribers?
Example 1
Example 2