summaryrefslogtreecommitdiff
path: root/examples/readwrite-futures.pl
blob: 9ab73b2e0954d2a78263bfff55bc68dde475c9e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/perl

use strict;
use warnings;

use IO::Async::Loop;
use IO::Async::Stream;

my $loop = IO::Async::Loop->new;

$loop->add( my $stdin  = IO::Async::Stream->new_for_stdin( on_read => sub { 0 } ) );
$loop->add( my $stdout = IO::Async::Stream->new_for_stdout );

$stdout->write( sub {
   return undef if $stdin->is_read_eof;
   return $stdin->read_atmost( 64 * 1024 );
})->get;