Created
November 17, 2016 09:06
-
-
Save khan5v/e1462b8a06f533fce179d333319aa90a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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