Skip to content

Instantly share code, notes, and snippets.

@khan5v
Created November 17, 2016 09:06
Show Gist options
  • Save khan5v/e1462b8a06f533fce179d333319aa90a to your computer and use it in GitHub Desktop.
Save khan5v/e1462b8a06f533fce179d333319aa90a to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use Data::Dumper;
use AnyEvent::Handle;
use AnyEvent;
my($pipe_w, $pipe_r);
pipe $pipe_r, $pipe_w;
my $cv = AnyEvent->condvar;
## Asynchronous buffers
my $wh = new AnyEvent::Handle(fh => $pipe_w);
my $rh = new AnyEvent::Handle(fh => $pipe_r);
$wh->push_write(json => ["112"]);
$rh->push_read(json => sub {
my($handle, $payload) = @_;
print Dumper $payload;
$cv->send;
});
$cv->recv;
undef $wh;
undef $rh;
close $pipe_w;
close $pipe_r;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment