UniEvent::Request::Write - stream write request
This is an internal purpose object and can be used for tracking 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, $request) = @_; say $tracked{$request}, " has been written"; }); ...; 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:
write
$stream->write('piece1', sub { say "piece1 has been written"; }); $stream->write('piece2', sub { say "piece2 has been written"; });
To install UniEvent, copy and paste the appropriate command in to your terminal.
cpanm
cpanm UniEvent
CPAN shell
perl -MCPAN -e shell install UniEvent
For more information on module installation, please visit the detailed CPAN module installation guide.