NAME
UniEvent::Request::Write - stream write request
DESCRIPTION
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:
$stream->write('piece1', sub {
say "piece1 has been written";
});
$stream->write('piece2', sub {
say "piece2 has been written";
});