[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: how to handle callbacks
- From: Gaspard Bucher <gaspard@...>
- Date: Tue, 14 Dec 2010 00:32:17 +0100
Hi there !
I am writing the wrappers around Zeroconf (mdns) registration and
browser. How this works is that I have to register a callback in C and
whenever a new device is found or removed, the callback is triggered.
I have two options:
1. The callback stores service arrival/departure in a global state (in
C, with mutex) and when the browser coroutine resumes, the browser
checks for data in this list (with a call in C).
2. The callback waits for a lock release on the LuaState and calls a
Lua function (that serves as a callback). This probably implies that I
have to compile Lua with lua_lock defined and find a way for Lua to
release the lock at some regular interval.
What is the best way to handle this ?
Thanks for your advice...
Gaspard