[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Can't interrupt tight loops in Lua 5.4 anymore?
- From: "Joseph C. Sible" <josephcsible@...>
- Date: Tue, 19 May 2020 18:02:00 -0400
On Tue, May 19, 2020 at 5:01 PM Sean Conner <sean@conman.org> wrote:
>
> I think it would be a bit faster if it was:
>
> if (L->globalhook != NULL)
> (*L->globalhook)(L);
>
> That way, it avoids the overhead of a function call.
>
> -spc
That's dangerous as written, because it could get changed to be NULL
in between when you check it and when you call it. You'd need to do
this instead:
lua_GlobalHook gh = L->globalhook;
if(gh != NULL)
(*gh)(L);
Having said that, I agree that'd be a lot faster, since indirect calls
are pretty slow, and usually there won't be a global hook. One other
note, though: to fix the coroutine issue, I was planning to put
globalhook in G(L) instead of in L.
Joseph C. Sible
- References:
- Can't interrupt tight loops in Lua 5.4 anymore?, Joseph C. Sible
- Re: Can't interrupt tight loops in Lua 5.4 anymore?, Roberto Ierusalimschy
- Re: Can't interrupt tight loops in Lua 5.4 anymore?, Andrew Gierth
- Re: Can't interrupt tight loops in Lua 5.4 anymore?, Roberto Ierusalimschy
- Re: Can't interrupt tight loops in Lua 5.4 anymore?, Viacheslav Usov
- Re: Can't interrupt tight loops in Lua 5.4 anymore?, Roberto Ierusalimschy
- Re: Can't interrupt tight loops in Lua 5.4 anymore?, Viacheslav Usov
- Re: Can't interrupt tight loops in Lua 5.4 anymore?, Roberto Ierusalimschy
- Re: Can't interrupt tight loops in Lua 5.4 anymore?, Joseph C. Sible
- Re: Can't interrupt tight loops in Lua 5.4 anymore?, Roberto Ierusalimschy
- Re: Can't interrupt tight loops in Lua 5.4 anymore?, Sean Conner