Skip to content

2.x: Scheduler implement a Clock interface #5678

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

Closed
davidmoten opened this issue Oct 17, 2017 · 5 comments
Closed

2.x: Scheduler implement a Clock interface #5678

davidmoten opened this issue Oct 17, 2017 · 5 comments

Comments

@davidmoten
Copy link
Collaborator

davidmoten commented Oct 17, 2017

I have frequently passed through a Scheduler instance to a class that only uses the now method (and does no scheduling). In the interests of clarity in my code (and to leverage compile time checking) I'd prefer to pass through a Clock instance (without creating another object to wrap the Scheduler). Would you mind if I submitted a PR with the addition of a new interface Clock that would be implemented by Scheduler?

@davidmoten davidmoten changed the title Scheduler implement a Clock interface 2.x: Scheduler implement a Clock interface Oct 17, 2017
@artem-zinnatullin
Copy link
Contributor

Well that sounds like wrong abstraction, scheduler shouldn't be source of time, it should depend on some source of time

See #3295

@akarnokd
Copy link
Member

Standard Schedulers return System.currentTimeMillis() and the TestScheduler returns an artificial value. Why is a wrapper so costly for you?

@davidmoten
Copy link
Collaborator Author

The wrapper is not costly, just more code to write or a dependency to add. If we had the interface we can use it internally as well, but this is just a convenience request that I'm assuming comes at little cost (?) and doesn't break apis.

@akarnokd
Copy link
Member

I'm not fond of the idea. We have no use for this type of abstraction in RxJava and you'd still have to use RxJava as dependency to access such abstraction. You could simply not fully implement a Scheduler, making the other methods throw UnsupportedOperationException.

@davidmoten
Copy link
Collaborator Author

Ok, I'll close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants