Skip to content
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

Merged
merged 1 commit into from
Apr 15, 2021

Conversation

idelpivnitskiy
Copy link
Member

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.

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.
@idelpivnitskiy idelpivnitskiy requested a review from bondolo April 15, 2021 19:14
* @param duration the duration to convert
* @return the converted nanoseconds value
*/
public static long toNanos(final Duration duration) {
Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Member Author

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) {
Copy link
Contributor

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.

@idelpivnitskiy idelpivnitskiy merged commit ee527ec into apple:main Apr 15, 2021
@idelpivnitskiy idelpivnitskiy deleted the d-toNanos branch April 15, 2021 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants