Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign uplibstd: Refactor Duration. #16626
Conversation
This comment has been minimized.
This comment has been minimized.
|
2^63 milliseconds is just shy of 300 million years. Do we really need to support the full range that i64 seconds gives us? It might be a better API to just restrict |
This comment has been minimized.
This comment has been minimized.
|
We could restrict it to |
This comment has been minimized.
This comment has been minimized.
|
As I said on the previous PR, I think it's acceptable for |
ruuda
referenced this pull request
Aug 21, 2014
Merged
libtime: Use Duration in Timespec arithmetic. #16650
This comment has been minimized.
This comment has been minimized.
brson
commented on 26af5da
Aug 26, 2014
|
r+ Thanks! |
This comment has been minimized.
This comment has been minimized.
|
saw approval from brson |
This comment has been minimized.
This comment has been minimized.
|
merging ruud-v-a/rust/duration-reform = 26af5da into auto |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Aug 26, 2014
This comment has been minimized.
This comment has been minimized.
|
The failures don’t seem to be related to the changes ... is there something I should fix? |
lilyball
reviewed
Aug 28, 2014
| assert!(Duration::days(MAX_DAYS).checked_add(&Duration::seconds(86400)).is_none()); | ||
| assert_eq!(Duration::milliseconds(i64::MAX - 1).checked_add(&Duration::microseconds(999)), | ||
| Some(Duration::milliseconds(i64::MAX - 2) + Duration::microseconds(1999))); | ||
| assert!(Duration::milliseconds(i64::MAX).checked_add(&Duration::microseconds(1000)).is_none()); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
The failure was
This is indeed something you need to fix. |
This comment has been minimized.
This comment has been minimized.
lilyball
commented on 447b64e
Aug 28, 2014
|
r=brson |
This comment has been minimized.
This comment has been minimized.
|
saw approval from brson |
This comment has been minimized.
This comment has been minimized.
|
merging ruud-v-a/rust/duration-reform = 447b64e into auto |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
fast-forwarding master to auto = 1a33d7a |
ruuda commentedAug 20, 2014
This changes the internal representation of
Durationfromto
This resolves #16466. Note that
nanosis ani32and notu32as suggested, becausei32is easier to deal with, and it is not exposed anyway. Some methods now takei64instead ofi32due to the increased range. Some methods, likenum_milliseconds, now return anOption<i64>instead ofi64, because the range ofDurationis now larger than e.g. 2^63 milliseconds.A few remarks:
MINis impossible. I chose to returnMAXas-MIN, but it is one nanosecond less than the actual negation. Is this the desired behaviour?std::io::timer, some functions accept aDuration, which is internally converted into a number of milliseconds. However, the range ofDurationis now larger than 2^64 milliseconds. There is already a FIXME in the file that this should be addressed (without a ticket number though). I chose to silently use 0 ms if the duration is too long. Is that right, as long as the backend still uses milliseconds?