Io::Manager - mfichman/jogo GitHub Wiki

The Io::Manager coordinates coroutines that have blocked waiting for I/O, and provides the core asynchronous I/O implementation. The Io::Manager is resposible for running an Jogo program's event loop; the Io::Manager is started first by the runtime, and the the main() coroutine is launched and added to the scheduled task queue.

Arbitrary tasks (named coroutines) can be added to the task queue. When a task is added to the task queue, it may be run the next time the current coroutine yields or blocks on I/O. When a task has finished running, the task is removed from the task queue.

@init()

Initializes a new manager. Most applications need only one I/O manager, which can be accessed via the Event::manager() constant.

@destroy()

Destroys the I/O manager, and releases the OS resources used for event polling.

task(task Coroutine)

Adds this task to the list of tasks waiting to be scheduled. The task will be run when all other tasks are blocked or if a task yields and the task is first on the task list. If the task blocks to do I/O, it will yield back to the I/O manager, which will schedule another task. If no tasks are available, then the I/O manager will wait on I/O.

run()

Run the event loop. Select a coroutine from the 'scheduled' queue, and begin executing it. If there are no more tasks, and no outstanding I/O requests, then return.

poll()

Poll for an I/O request. This function will block until an I/O operation finishes.

shutdown()

Shuts down the I/O manager; no additional I/O operations can be done after this method is called.

scheduled=(_arg0 Queue[Coroutine])

No comment

scheduled?() Queue[Coroutine]

No comment

handle=(_arg0 Int)

No comment

handle?() Int

No comment

iobytes?() Int

No comment