-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-implement scheduler's related code #277
Comments
Operator's scheduler can't be It is why i've mentioned it in RxCpp repository: ReactiveX/RxCpp#593 For example: rpp::source::just(rpp::schedulers::trampoline{}, 1, 1, 1)
.merge_with(rpp::source::just(rpp::schedulers::new_thread{}, 2, 2, 2))
.observe_on(rpp::schedulers::trampoline{})
.as_blocking()
.subscribe([](int v)
{
std::cout << "==================\n" << std::this_thread::get_id() << " START " << std::endl;
std::this_thread::sleep_for(std::chrono::seconds{1});
std::cout << v << std::endl;
std::cout << std::this_thread::get_id() << " END " << std::endl << "==================\n\n";
}); Can produce something like:
So, it would be forbidden to use trampoline scheduler in operators! If you have some good points why it is incorrect - feel free to submit issue mentioning this one =) UPD: rpp::source::just(1,2,3,4,5,6)
.delay(delay_duration, rpp::schedulers::trampoline{}) but in this case just not =C rpp::source::just(1,2,3,4,5,6)
.merge_with(rpp::source::just(rpp::schedulers::new_thread{}, 1,2,3,4)
.delay(delay_duration, rpp::schedulers::trampoline{}) |
I see the problem. But I feel the problem is probably inside the trampoline implementation that I initially wrote. Let me explain:
The trampoline's behavior in the existing code schedule the emission of observable in But the ideal expectation is supposed, we should remember the thread local queue of the thread that we create the trampoline scheduler. In this case, it's the host thread for That way the trampoline follows the rule of serialized outputs and be useful for unit tests. |
Looks like i've found solution!
Then in this case: rpp::source::just(1,2,3,4,5,6)
.delay(delay_duration, rpp::schedulers::trampoline{}) it would be thread_local everytime. rpp::source::just(1,2,3,4,5,6)
.merge_with(rpp::source::just(rpp::schedulers::new_thread{}, 1,2,3,4)
.delay(delay_duration, rpp::schedulers::trampoline{}) it can be any:
@tcw165, what do you think? BTW @kirkshoop, if you see it, also interested in your opinion =) UPD: After a lot of investigation of this issue looks like i've found correct solution:
As a result, while we have "non empty queue", then we use same scheduler. If queue becomes empty, then next "scheduling" would really use scheduler and can change thread if needed |
UPD:
The text was updated successfully, but these errors were encountered: