-
Notifications
You must be signed in to change notification settings - Fork 7.6k
SchedulePeriodically Signature #856
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
SchedulePeriodically Signature #856
Conversation
public Subscription schedulePeriodically(final Action1<Scheduler.Inner> action, long initialDelay, TimeUnit delayUnit, long period, TimeUnit periodUnit)
RxJava-pull-requests #780 SUCCESS |
I don't know that this change is worth pursuing and being different than Executor. It's easy enough to use as is and convert from languages like Scala (as it's wrapper already does). Some day (maybe v2.0) when we support Java 8 as the minimum we could then use Agreement? Disagreement? Evidently I'm not strongly opinionated either way on this one so feedback would be helpful. @headinthebox Since you are a proponent for this change, please weigh in. |
Why not have two overloads? That should work just fine |
Using overload is a safe way, but we need to add overloads to operators which take 2 durations (such as Timer, Buffer and Window). |
Yes, I mentioned that earlier. |
Only because we have been trying to eliminate overloads. An overload of this one feels like it means we can't decide. |
In that case, my preference is clear ;-) |
@akarnokd Should we merge this change and adopt the new signature, or stick with the Java @abersnaze I believe you are in favor of merging this change, correct? |
public Subscription schedulePeriodically(final Action1<Scheduler.Inner> action, long initialDelay, long period, TimeUnit unit) { | ||
final long periodInNanos = unit.toNanos(period); | ||
public Subscription schedulePeriodically(final Action1<Scheduler.Inner> action, long initialDelay, TimeUnit initialDelayUnit, long period, TimeUnit periodUnit) { | ||
final long periodInNanos = periodUnit.toNanos(period); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather chose a common unit here instead of converting to nanos.
TimeUnit common = initialDelayUnit.compareTo(periodUnit) < 0 ? initialDelayUnit : periodUnit;
final long initial = common.convert(initialDelay, initialDelayUnit);
final long period = common.convert(period, periodUnit);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The common unit is nanos. It already was before this change.
My preference would be to stick with the Java convention. Ideal thing would be to have a single object encapsulating the delay unit and time but that is not an option currently. |
Isn't there a scala wrapper anymore where this could be shifted over? I would support the new split syntax only if the current overload is kept with deprecated annotation until the time of the major purge. |
Yes, the Scala wrapper already does it this way. |
I'm closing this out, the reasoning for doing it is not strong enough as languages like Scala can already deal with it whereas in Java the way it is currently is idiomatic. |
This pull requests adds
TimeUnit delayUnit
to the signature:This was derived from feedback from @headinthebox while writing the Scala APIs.
Reason for ...
Duration
: http://download.java.net/jdk8/docs/api/java/time/Duration.htmlReason against ...
Duration
still doesn't use it on theirScheduledExecutorService
Thoughts, concerns, opinions?