-
-
Notifications
You must be signed in to change notification settings - Fork 345
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
Is it better to have sleep(0), sleep(x), sleep(inf), or checkpoint(), sleep(x), sleep_forever()? #310
Comments
IMHO overlaying sleep with both "provide a cancellation point" i.e. sleep(0) and "wait until cancelled" = sleep(inf) is somewhat less than optimal because when I'm scanning the documentation for a function that provides one of these concepts I'm not searching for "sleep" – I'm likely to look for "suspension point" or "forever" respectively. Thus I'm mildly in favor of keeping "special" functions for these purposes, if only as aliases. |
I'm strongly in favor of this change, primarily for pedagogical reasons - instead of presenting the Special-casing the implementation(s) is probably a good idea, so long as the code is reasonable. Magic clocks might also need to have distinct handling for infinite sleeps or timeouts? |
See also #655, where @joernheissler quotes the bits of the doc talking about
I can see the arguments both ways here: This is basically a tiny style judgment call, so I'm going to procrastinate on it for now. We've got the "potential API breaker" tag on it, so we'll definitely see it again before 1.0, if not before. And maybe with more experience we'll have a better "feel" for which makes sense. |
I find myself writing |
Speaking of cleaning up names and namespaces,
sleep_forever
is also accessible assleep(inf)
orsleep_until(inf)
. Does it really need a top-level name? And frankly thesleep_forever
name is kinda confusing – wouldn'twait_cancelled
or something make more sense?Maybe we should make it so the
inf
versions ofsleep
special case this for the marginal efficiency gain (likesleep(0)
does), and then make that the One Way of getting these semantics.The text was updated successfully, but these errors were encountered: