NAME
UniEvent::Request::Shutdown - stream write request
DESCRIPTION
The entire purpose of the class is to allow track write requests. It can be used to identify, which pieces of data has been written, e.g.:
my %tracked;
$stream->write_callback(sub {
my ($stream, $error_code, $request) = @_;
... if $error_code;
say @{ $tracked{$request} }, " has been written to network";
});
...;
my $piece1 = \"piece1";
my $piece2 = \"piece2";
my $r1 = $stream->write($$piece1);
$tracked{$r1} = $piece1;
my $r2 = $stream->write($$piece2);
$tracked{$r2} = $piece2;
As the alternative, the one-shot callback can be used with write
method, howerver it might be less convenient:
$stream->write('piece1', sub {
my ($stream, $error_code) = @_;
... if $error_code;
});
$stream->write('piece2', sub {
my ($stream, $error_code) = @_;
... if $error_code;
});
METHODS
There are no methods