duktape
duktape copied to clipboard
Improve executor timeout mechanism
- [ ] Rate limit the callbacks based on Date-provided timestamp check (avoid checking too often as it may be expensive to get current time)
- [ ] Add timeout propagation state explicitly into Duktape state (instead of relying on the callback consistently indicating timeout until the RangeError has fully bubbled out)
- [ ] Rework into an actual API call because this is a generally useful feature (unlike e.g. low memory options)
+1 for improvements regarding suspend/resume discussed in #90
I'm also looking for context-switching. e.g. running multiple contexts with some kind of scheduler. With suspend/resume (or run_this_context(context, opsToRunBeforeBreak)) would make it possible to write long-running code ("while(true)" for example) without blocking other contexts for too long.
A related feature that could be supported by the API is a sort of watchdog timer.
I'm currently working with an event loop, something like the following:
while(SendHeartBeat()) {
// do work that *should* take a short amount of time
}
SendHeartBeat is written in C. So long as it is called regularly, we know that the work is taking a short amount of time. If it isn't called, the code has hung for some reason and we want to abort it.
FWIW, this issue was mentioned over on the polkit
issue tracker.
Looks like polkit
is considering switching to duktape over mozjs, as the latter greatly complicates the build process with all of the compile-time dependencies mozjs pulls in.
Might want to coordinate with the polkit
devs.