Closed timstableford closed 3 years ago
The code intends that if I call setTimeout
multiple times, it will hook multiple times, is this supposed to happen?
I believe it's now correct. When lua_sethook is called it replaces the previous hook rather than adding a new one. So when setTimeout it called with 0 it lua_sethooks to null and when with a non-zero value it sets it to the hooks function pointer. This way when it's disabled the hook isn't unnecessarily called.
If disabled then it would the hook would be set to null in C but then on the next call the hook would not be fully re-enabled because it already existed.
Introduced in #36 but I only noticed after it'd been merged :)