[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: use of invalid L in libevent wrapper from Lua Programming Gems
- From: Sam Roberts <vieuxtech@...>
- Date: Sun, 20 Dec 2009 12:21:50 -0800
On Sun, Dec 20, 2009 at 4:34 AM, Wim Couwenberg
>> This patch uses static globals, so isn't thread safe, but since the
>> libevent event_dispatch() API isn't thread-safe either, that shouldn't
>> be a problem.
> Instead of a static global you could store the dispatching state in a
> (not light) userdata in the registry. Then it is accessible form all
> Lua states (where events are created) and its address is fixed.
It's not clear to me exactly what you mean. This may or may not work
depending on how void handler() is written. I'll be interested in
seeing the patch, if you ever do it.
Anyhow, I'm not using libevent, I'm just reading the book to broaden
my exposure to lua idioms, and noticed that the code as written had
this subtle bug.