This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
SoulSystem's profile picture

A Question about os.pullEvent()/os.pullEventRaw() and Coroutines

Started by SoulSystem, 23 July 2013 - 10:23 AM
SoulSystem #1
Posted 23 July 2013 - 12:23 PM
Title: A Question about os.pullEvent()/os.pullEventRaw() and Coroutines

So after learning that os.pullEvent() and os.pullEventRaw() both call coroutine.yield(), I scoured the internet trying to find out exactly what these functions yield to. I still haven't found an answer. So my question is what do these functions yield to and would it be possible to create my own events (or take advantage of existing events) without calling os.queueEvent()?
Lyqyd #2
Posted 23 July 2013 - 08:42 PM
Split into new topic.

Eventually, they yield to the Java side of things to get new events. Essentially though, unless you are creating a coroutine manager, you can usually ignore the actual nature of what you're really yielding to and just consider it to be a magical source of event-bearing resumes. If you're creating a coroutine manager, check out the parallel API code to get an idea of what the coroutine manager's responsibility is.

Edit: to create your own events, you can either queue them, or be the coroutine manager for the coroutines you want to receive the events.