-
Notifications
You must be signed in to change notification settings - Fork 184
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
Move Publisher#toNanos
to DurationUtils
#1493
Conversation
Motivation: `Publisher` is already a complicated class. We should not expand its scope by additional utilities, even if they are internal. We have a better place for `Publisher#toNanos` now - `DurationUtils`. Modifications: - Move `Publisher#toNanos` to `DurationUtils`; Result: Less utilities in `Publisher`, all `compareTo` operations for `Duration` are in a single place.
* @param duration the duration to convert | ||
* @return the converted nanoseconds value | ||
*/ | ||
public static long toNanos(final Duration duration) { |
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.
does it make sense to qualify the name to indicate under/overflow protection? For example in FlowControlUtils
we use WithUnderOverflowProtection.
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'm fine with it being in the method documentation. In particular, I expect this method will be obsolete when we move to Java 11 which includes a method with the same behaviour on TimeUnit
including the underflow/overflow protection.
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.
+1, let's keep as-is. It's an internal method anyway
* @param duration the duration to convert | ||
* @return the converted nanoseconds value | ||
*/ | ||
public static long toNanos(final Duration duration) { |
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'm fine with it being in the method documentation. In particular, I expect this method will be obsolete when we move to Java 11 which includes a method with the same behaviour on TimeUnit
including the underflow/overflow protection.
Motivation:
Publisher
is already a complicated class. We should not expand itsscope by additional utilities, even if they are internal. We have a
better place for
Publisher#toNanos
now -DurationUtils
.Modifications:
Publisher#toNanos
toDurationUtils
;Result:
Less utilities in
Publisher
, allcompareTo
operations forDuration
are in a single place.