Name
SPVM::IO::Select - select System Call
Description
IO::Select class in SPVM has methods for select
system call.
Usage
use IO::Select;
my $select = IO::Select->new;
$select->add($fd0);
$select->add($fd1);
my $read_ready_fds = $select->can_read($timeout);
my $write_ready_fds = $select->can_write($timeout);
Details
This class is a Perl's IO::Select porting to SPVM.
Fields
fds_list
has fds_list : IntList;
A list of file descriptors.
Class Methods
new
static method new : IO::Select ();
Creates a new IO::Select object and returns it.
Internally, a IntList object with zero-length is created, and "fds_list" is set to it.
Instance Methods
add
method add : void ($fd : int);
Adds the file descriptor $fd to "fds_list" field.
If $fd is already contained in "fds_list" field, nothing is performed.
remove
method remove : void ($fd : int);
Removes the file descriptor $fd from "fds_list" field.
If $fd is not found, nothing is performed.
exists
method exists : int ($fd : int);
If the file descriptor $fd is contained in "fds_list" field, returns 1, otherwise returns 0.
fds
method fds : int[] ();
Converts "fds_list" field to an array and returns it.
count
method count : int ();
Returns the length of "fds_list" field.
can_read
method can_read : int[] ($timeout : double = -1);
Returns readable file descriptors in "fds_list" field.
This method calls Sys::Select#select method.
The timeout $timeout specifies the minimum interval that select() system call should block waiting for a file descriptor to become ready. If $timeout is 0, then select() returns immediately. If $timeout is a negative value, select() can block indefinitely.
can_write
method can_write : int[] ($timeout : double = -1);
Returns writable file descriptors in "fds_list" field.
The timeout $timeout specifies the minimum interval that select() system call should block waiting for a file descriptor to become ready. If $timeout is 0, then select() returns immediately. If $timeout is a negative value, select() can block indefinitely.
has_exception
method has_exception : int[] ($timeout : double = -1);
Returns file descriptors that causes exceptions in "fds_list" field.
The timeout $timeout specifies the minimum interval that select() system call should block waiting for a file descriptor to become ready. If $timeout is 0, then select() returns immediately. If $timeout is a negative value, select() can block indefinitely.
See Also
Copyright & License
Copyright (c) 2023 Yuki Kimoto
MIT License