[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua in a threaded enviroment
- From: Chris Jones <cmsj@...>
- Date: Wed, 31 Aug 2016 12:14:56 +0200
Depending on your target platform, and since you can only ever have one thread executing Lua at a time, it may be easier to dispatch the work to happen on the main thread. We do this in Hammerspoon (OS X) using Apple's SDK (things like dispatch_sync(), dispatch_async() and [NSObject performSelectorOnMainThread]).
(For the sake of safety, we also perform a sanity check almost every time a C function is about to do some Lua work, to make sure it's happening on the main thread)