Name
SPVM::IO::Pipe::End - Pipe End with Goroutines and Deadlines
Description
SPVM::IO::Pipe::End represents one end of a non-blocking pipe. It inherits from SPVM::IO::Handle and is integrated with SPVM::Go for cooperative scheduling and deadline management.
Usage
use IO::Pipe;
use Go;
use Go::Time;
my $pipe = IO::Pipe->new;
my $handles =$pipe->handles;
# Write data to the pipe
$handles->[1]->syswrite("Hello SPVM Pipe");
# Read data from the pipe
my $buffer = (mutable string)new_string_len(100);
$handles->[0]->sysread($buffer);
Goroutine and Non-blocking I/O
All I/O operations in this class (`sysread`, `syswrite`, etc.) are non-blocking and integrated with goroutines.
If an I/O operation cannot be completed immediately, the current goroutine yields control to the Go scheduler, allowing other goroutines to run. When the pipe becomes ready, the goroutine is automatically resumed.
Super Class
Instance Methods
new
static method new : IO::Pipe::End ($options : object[] = undef);
Creates a new IO::Pipe::End object by calling "init" method with $options.
init
protected method init : void ($options : object[] = undef);
Initializes the pipe end handle.
sysread
method sysread : int ($string : mutable string, $length : int = -1,$offset : int = 0);
Performs non-blocking read operation on the pipe.
If no data is available, it yields until the pipe is ready, the inactivity timeout expires, or the read deadline is reached.
Exceptions:
Exceptions thrown by Go#gosched_pipe_read method could be thrown.
syswrite
method syswrite : int ($string : string, $length : int = -1,$offset : int = 0);
Performs non-blocking write operation on the pipe.
If the buffer is full, it yields until space becomes available, the inactivity timeout expires, or the write deadline is reached.
Exceptions:
Exceptions thrown by Go#gosched_pipe_write method could be thrown.
close
method close : void ();
Closes the pipe file descriptor and cancels any pending I/O operations on it.
Exceptions:
If this handle is not opened or already closed, an exception is thrown.
See Also
Copyright & License
Copyright (c) 2026 Yuki Kimoto
MIT License