A task-based interface to the uv loop
The I/O task runs in its own single-threaded scheduler. By using the interact
function you can execute code in a uv callback.
IoTaskLoopData
IoTask
- Used to abstract-away direct interaction with a libuv loop.IoTaskMsg
begin_teardown
exit
- Shut down the I/O taskinteract
- Provide a callback to be processed by iotask
run_loop
- Run the loop and begin handling messagessend_msg
spawn_iotask
tear_down_close_cb
wake_up_cb
- Dispatch all pending messagesIoTaskLoopData
type IoTaskLoopData = {async_handle: *ll::uv_async_t, msg_po: Port<IoTaskMsg>,}
IoTask
Used to abstract-away direct interaction with a libuv loop.
IoTask_({async_handle: *ll::uv_async_t, op_chan: Chan<IoTaskMsg>,})
IoTaskMsg
Interaction(~fn(*libc::c_void))
TeardownLoop
begin_teardown
fn begin_teardown(data: *IoTaskLoopData)
exit
fn exit(iotask: IoTask)
Shut down the I/O task
Is used to signal to the loop that it should close the internally-held async handle and do a sanity check to make sure that all other handles are closed, causing a failure otherwise.
interact
fn interact(iotask: IoTask, cb: ~fn(*c_void))
Provide a callback to be processed by iotask
The primary way to do operations again a running iotask
that doesn't involve creating a uv handle via safe_handle
This function is the only safe way to interact with any iotask
. Using functions in the uv::ll
module outside of the cb
passed into this function is very dangerous.
uv_loop_t*
. In the context of this callback, it is safe to use this pointer to do various uv_* API calls contained within the uv::ll
module. It is not safe to send the loop_ptr
param to this callback out via ports/chans.run_loop
fn run_loop(iotask_ch: Chan<IoTask>)
Run the loop and begin handling messages
send_msg
fn send_msg(iotask: IoTask, msg: IoTaskMsg)
spawn_iotask
fn spawn_iotask(task: task::TaskBuilder) -> IoTask
tear_down_close_cb
fn tear_down_close_cb(handle: *ll::uv_async_t)
wake_up_cb
fn wake_up_cb(async_handle: *ll::uv_async_t, status: int)
Dispatch all pending messages