BabylonNative
BabylonNative copied to clipboard
Make `setTimeout` asynchronous and add `clearTimeout`
Overview
Improves setTimeout
performance by making it asynchronous, and implements clearTimeout
.
Details
The current implementation of setTimeout
dispatches repeatedly until the given delay is reached. This causes performance issues.
This PR fixes the issue by building on the initial investigative work done in PR https://github.com/BabylonJS/BabylonNative/issues/843 to implement setTimeout
asynchronously on a separate thread.
The clearTimeout
function is currently not implemented and since it is closely related to setTimeout
, it makes sense to implement it in this change, too.
Related tickets
https://github.com/BabylonJS/BabylonNative/issues/253 https://github.com/BabylonJS/BabylonNative/issues/893
It might also be good to add some unit tests.
@docEdub Don't forget to add unit tests here: https://github.com/BabylonJS/BabylonNative/blob/master/Apps/UnitTests/Scripts/tests.js It's handy because it runs on Mac and Linux as well.