lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I wqould say that if your application requires a blocking pcall, that application MUST NOT run in the main UI thread but must run in another thread that you can suspend by yielding back to the UI thread, where your Lua wrapper will just be a "very light" event dispatcher  (that will resume the application's thread when needed according to some "wait" condition)

It's perfectly possible to write a blocking behavior outside the main UI thread. 

The dispatcher will resume the application by giving it the event, the application will determine if that event is sufficient to exit its blocking event loop and return from its local "pcall"; if that event does not wualify, the application will yield back to the main thread of the dispatcher or to other competing threads, discarding that event).

For all this, you just need to use coroutines: your blocking application will be running in a separate coroutine that can be suspended and resumed at any time and your application is free to yield() at any time, even in non-blocking situations (and here also the light dispatcher in the main thread can handle that situation).