-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Stabilize "Deno.sleepSync" API #14708
Comments
@ry might have objections here. I know he didn't really like the API back when. |
Also, we should check that the same functionality isn't already possible with just const sab = new SharedArrayBuffer(1024);
const int32 = new Int32Array(sab);
const timeout = 1000; // 1s
Atomics.wait(int32, 0, 0, timeout); |
Apparently the issue with We discussed this super briefly in the design meeting and if there's a way we could provide a helper in deno.land/std for doing this with I do really think we should have a way to sleep synchronously though as it can provide a more accurate sleep mechanism for some non-web server applications (ex. when using hardware). |
sleepSync has no utility - it's very easy to misuse - let's remove it not stabilize it. |
...for web servers |
It's very trivial to write a sleepSync that does this: const end = Date.now() + 1_000;
while (Date.now() < end); But it's fairly nontrivial to implement a sleepSync that works in all contexts and doesn't busyloop the CPU, so seems fairly reasonable to have Deno.sleepSync imo (with a big JSDoc warning) |
It's been unstable long enough, there's really not much to it.
It would allow to refactor and remove some code from
deno_web
extension, namelyTimerPermissions
trait wouldn't need to havecheck_unstable
method.The text was updated successfully, but these errors were encountered: