Posted 16 October 2012 - 08:23 PM
After looking at the code this looks to be, basically, an event distributor. The controller pulls an event and cycles through all coroutines created by the waitFor<Any | All>(). If a coroutine is requesting that event, it is passed to the coroutine.
Is this correct? I am trying to determine my options, and having a grasp on the parallel API will help with my decision. Essentially I want to simulate a read() call remaining open yet still be able to pull other events.
Perhaps I am going about this in the wrong way. Would this accomplish my goal better than parallel/coroutines?
My main issue is that I don't want any events to go unnoticed. Does CC use an event queue? Or would an event be lost if it occurred while no pullEvent was active?
Is this correct? I am trying to determine my options, and having a grasp on the parallel API will help with my decision. Essentially I want to simulate a read() call remaining open yet still be able to pull other events.
Perhaps I am going about this in the wrong way. Would this accomplish my goal better than parallel/coroutines?
while true do
local input
local evt = {os.pullEvent()}
if evt[1] == "char" then input = input .. evt[2]
elseif evt[1] == "key" then
--'Process keys like Enter and Backspace and arrows'
else
--'You get the idea.'
end
end
My main issue is that I don't want any events to go unnoticed. Does CC use an event queue? Or would an event be lost if it occurred while no pullEvent was active?