-
Notifications
You must be signed in to change notification settings - Fork 232
RFC: rename DelayNs to Delay #541
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
Comments
Would it be useful to switch to Users of the trait now have significantly less range to delay the core. Max delay is now ~4.29 seconds. Previously, the maximum was ~4,294 seconds. |
The trait still has |
We discussed this again today and didn't reach a firm conclusion, so probably default to not renaming this, but I'll leave the issue open another week in case anyone else wants to chime in. |
If you look at the inner implementation of If this isn't a concern, since users could call |
They don't? The provided default implementation (the final implementer can override) makes multiple calls to |
You're right, I misread the implementation somehow late last night, and thought there was only a single call. |
In the end we decided not to do this for 1.0, i'm closing this to keep the roadmap clear. |
The obvious name for the
DelayNs
trait isDelay
, but we've reserved that name for a future, post-1.0 trait once we have a goodDuration
. Right now it's not clear what thatDuration
will look like or do, so we've been leaving thinking about it until later.I suggest we rename the current
DelayNs
trait toDelay
now anyway:DelayNs
already does everything we want: pick a number of ns/us/ms to delay for, up to u32 of them, and you can always do it multiple times if that's not enough rangeDuration
type, it would be nicer to be stuck withDelay
thanDelayNs
;delay(Duration)
toDelay
and provide a default implementation in terms ofdelay_ns()
; if we keepDelayNs
then once we findDuration
we'll end up with both the new, goodDelay
and the old-but-kept-foreverDelayNs
My main point is that perhaps what we have in
DelayNs
is already good enough to warrant using the nameDelay
, and it's nice that we could conceivably add adelay(Duration)
method later (with some caveats) if we wanted to, while if we stick withDelayNs
now, we're sure to always haveDelayNs
and maybe also haveDelay
, with all the confusion that multiple overlappnig traits has brought us in the past.There are some downsides to "just add
delay(Duration)
later", though:delay_ns
, whereas the obvious de-novo construction would be to defaultdelay_ms/us/ns
in terms ofdelay(Duration)
. This is a pain, but I don't think it constrains whatDuration
looks like (presumably we'll need to be able to convert it to ns somehow anyway), and we can document that implementors should prefer to implementdelay()
themselves, and then implementdelay_ns
in terms ofdelay
.Delay
, which could be used to require a certain timebase for example. I don't fully understand the negative consequences here, but maybe @Dirbaio can expand on them later.Delay
trait to only ever havedelay(Duration)
, withoutdelay_ms()
methods, as is done in the stdlib. We couldn't do this rename and then later delete those methods, so we would be stuck with them inDelay
.It's not a slam-dunk either way, but it seemed worth discussing before we hit 1.0.
The text was updated successfully, but these errors were encountered: