Name

SPVM::Go::UV::Loop - libuv Event Loop

Description

Go::UV::Loop class in SPVM represents an event loop in libuv.

Usage

use Go::UV::Loop;
use Go::UV::Constant as UV_C;

my $uv_loop = Go::UV::Loop->new;

$uv_loop->run(UV_C->UV_RUN_DEFAULT);

Fields

uv_handles_h

has uv_handles_h : Hash of Go::UV::Handle;

A hash that holds active handles associated with this event loop.

Class Methods

new

static method new : Go::UV::Loop ();

Creates a new libuv loop.

Exceptions:

If uv_loop_init fails, an exception is thrown.=head1 Instance Methods

run

method run : int ($uv_run_mode : int);

Runs the event loop with the specified mode, and returns the return value of uv_run.

See Go::UV::Constant for constants such as UV_RUN_XXX specified at $uv_run_mode.

idle_init

method idle_init : void ($uv_idle : Go::UV::Handle::Idle);

Initializes an idle handle $uv_idle associated with the event loop. See uv_idle_init.

Exceptions:

$uv_idle must be defined. Otherwise an exception is thrown.

timer_init

method timer_init : void ($uv_timer : Go::UV::Handle::Timer);

Initializes a timer handle $uv_timer associated with the event loop. See uv_timer_init.

Exceptions:

$uv_timer must be defined. Otherwise an exception is thrown.

If uv_timer_init fails, an exception is thrown.

poll_init

method poll_init : void ($uv_poll : Go::UV::Handle::Poll, $fd : int);

Initializes a poll handle $uv_poll for the given file descriptor $fd associated with the event loop. See uv_poll_init.

Exceptions:

$uv_poll must be defined. Otherwise an exception is thrown.

If uv_poll_init fails, an exception is thrown.

Exceptions:

$uv_async must be defined. Otherwise an exception is thrown.

$cb must be defined. Otherwise an exception is thrown.

If uv_async_init fails, an exception is thrown.

async_init

method async_init : void ($uv_async : Go::UV::Handle::Async, $cb : Go::UV::Callback::Async);

Initializes an async handle $uv_async associated with the event loop with a callback $cb. Go::UV::Handle::Async#async_cb field is set to $cb. See uv_async_init.

Exceptions:

$uv_pipe must be defined. Otherwise an exception is thrown.

If uv_pipe_init fails, an exception is thrown.

pipe_init

method pipe_init : void ($uv_pipe : Go::UV::Handle::Pipe, $ipc : int);

Initializes a pipe handle $uv_pipe associated with the event loop with $ipc. See uv_pipe_init.

DESTROY

method DESTROY : void ();

Destroys the event loop and releases its resources. See uv_loop_close.

Exceptions:

If uv_loop_close fails, an exception is thrown.