-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Feature request: Support async unref for timers #6141
Comments
Hi @cknight, @ry, I would like to pick this up. My plan is as follow
interface Timer {
...
unref: boolean;
}
if args.unref {
Ok(JsonOp::AsyncUnref(f.boxed_local()))
} else {
Ok(JsonOp::Async(f.boxed_local()))
}
|
Why is |
@kitsonk In short, because a sub-module may setup the timeout or interval, and a sub-module can never know when the process is complete. Therefore, the sub-module cannot call Specifically, for my use case mentioned above, I had wanted to run a |
Understood... would We should try to extend browser paradigms where possible. |
If I understand you correctly, Browser windows "run" forever until closed by the user. This is a different paradigm to a deno process which can have a natural end. |
Looking at how Node.js does it, I can see your point... It feels like |
I just ran into this issue as well. I want to use setInterval to have code executed periodically in my program, but I do not want it to block the exit of the application when the main code has completed. Has there been any progress on this? |
Use case: As a a module developer, I want to run periodic tasks during the execution of my module. This can be accomplished via
setTimeout
orsetInterval
for example. However, I do not want these timers to block the exiting of my module.setInterval
in particular will cause the module to run forever until theid
associated with it is cleared.Specific use case:
std/log
file handler now uses a buffer to write log messages. Google and Go's glog implementations both use a log daemon to flush the buffer automatically every 30 seconds. It would be good forstd/log
file handler to usesetInterval
to flush the buffer every 30 seconds as well to mimic this but not block module exit. (see also ref #6127)For starters, there is already support for async unref ops within Deno which would likely be used in this solution.
The text was updated successfully, but these errors were encountered: