Open iam opened 4 years ago
Is this behavior intentional?
Calling std::thread::detach in the new_worker constructor will always throw std::system_error https://github.com/ReactiveX/RxCpp/blob/master/Rx/v2/src/rxcpp/schedulers/rx-newthread.hpp#L84
std::thread::detach
new_worker
std::system_error
if (keepAlive->worker.joinable() && keepAlive->worker.get_id() != std::this_thread::get_id()) { guard.unlock(); keepAlive->worker.join(); } else { keepAlive->worker.detach(); // always throws system_error }
The above detach could get executed when joinable returns false, but according to https://en.cppreference.com/w/cpp/thread/thread/detach if joinable returns false then system_error is always thrown.
detach
joinable
false
Should lines 83-85 be changed to add an if joinable?
if joinable
else if (keepAlive->worker.joinable()) { keepAlive->worker.detach(); }
Is this behavior intentional?
Calling
std::thread::detach
in thenew_worker
constructor will always throwstd::system_error
https://github.com/ReactiveX/RxCpp/blob/master/Rx/v2/src/rxcpp/schedulers/rx-newthread.hpp#L84The above
detach
could get executed whenjoinable
returnsfalse
, but according to https://en.cppreference.com/w/cpp/thread/thread/detach ifjoinable
returnsfalse
then system_error is always thrown.Should lines 83-85 be changed to add an
if joinable
?