3 ms·
I'm not exactly clear on how he's using coroutines to handle async callbacks. Can anyone help explain it?
by iamwil 14y ago
I'm not exactly clear on how he's using coroutines to handle async callbacks. Can anyone help explain it?
- chrisfarber 14y agoSure. I basically take the async callback and wrap it in a coroutine before I invoke it. If the coroutine yields back a function, I assume that that function can be repeatedly invoked until it returns a truthy value indicating it wants to resume. Unfinished coroutines are then kept in a table, and after each event from the ComputerCraft environment, I check the table of unfinished callbacks to see which ones can be resumed.