-
Notifications
You must be signed in to change notification settings - Fork 409
new_thread scheduler thread safety #492
Copy link
Copy link
Closed
Description
Thread sanitizer detects a data race in the following code:
rxcpp::composite_subscription lifetime;
auto worker =
rxcpp::observe_on_new_thread().create_coordinator(lifetime).get_worker();
std::vector<std::thread> threads;
for (int i = 0; i < 20; ++i) {
threads.emplace_back([&worker] {
worker.schedule([&worker](const auto &) {
for (size_t i = 0; i < 4294967292l / 6; ++i)
;
printf("Work\n");
});
});
}
for (auto &t : threads) {
t.join();
}
lifetime.unsubscribe();Should this bool be made atomic, or there is some other issue with the scheduler?
RxCpp/Rx/v2/src/rxcpp/rx-scheduler.hpp
Line 97 in ce5dfc2
| mutable bool isallowed; |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels