DelSkayn / rquickjs

High level bindings to the quickjs javascript engine
MIT License
434 stars 59 forks source link

Expose a on_tick function to improve callback task performance #239

Open richarddd opened 7 months ago

richarddd commented 7 months ago

In it's current state, all async tasks require a ctx.spawn. This works great but becomes highly inefficient when dealing with a very large number of async tasks (thousands or tens of thousands).

QuickJS has a poll function that gets called on every tick: https://github.com/bellard/quickjs/blob/2788d71e823b522b178db3b3660ce93689534e6d/quickjs-libc.c#L2080

It would be very useful to have this functionality in rquickjs.

That way we could implement timers and async callbacks with better performance as a complement to ctx.spawn.

Similarly this would allow users to add other capabilities such as signal handling.