-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
What is ObserveOnTimeProvider
intended / useful for?
#261
Comments
TimeProvider serves the role of |
@neuecc Thanks for the quick reply. Might be a silly question, but why do you need a timer for it if you only ever use the https://learn.microsoft.com/en-us/dotnet/api/system.timeprovider.createtimer?view=net-8.0#parameters
|
First, generating and executing a Timer for each individual value must absolutely be avoided for performance reasons. By the way, giving special treatment to TimeProvider.System by making it ObserveOnThreadPool is done for higher performance optimization. |
Really interesting project. We're heavily using RxNet and could benefit from a lower overhead implementation.
I was looking through the sources and especially into how
ObserveOn(..)
is implemented. After looking into it I don't get whatObserveOnTimeProvider
is for. An explanation would be appreciated.ObserveOnTimeProvider
is only created when ObserveOn is called with the non systemTimeProvider
.The internal
_Observer
class of theObserveOnTimeProvider
creates a stopped timer that (It seems) never elapses.R3/src/R3/Internal/TimeProviderExtensions.cs
Lines 5 to 8 in 9b18209
After values arrive in the
_Observer
this extension method is called on the timer:R3/src/R3/Internal/TimeProviderExtensions.cs
Lines 10 to 13 in 9b18209
According to the docs this timer is invoked immediately but never called periodically.
In this test case the
FakeTimeProvider
is not advanced, but the elements still end up in the output list.R3/tests/R3.Tests/OperatorTests/ObserveOnTest.cs
Lines 34 to 50 in 9b18209
What is the
ObserveOnTimeProvider
used for if it just immediately passes on messages, even if time stands still from the timers perspective?The text was updated successfully, but these errors were encountered: