Skip to content

Instantly share code, notes, and snippets.

@ryan5500
Created August 21, 2009 02:25
Show Gist options
  • Save ryan5500/171604 to your computer and use it in GitHub Desktop.
Save ryan5500/171604 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
#use AnyEvent;
use AnyEvent::Strict;
use AnyEvent::Run;
my $match_time_start = AnyEvent->condvar;
my $wait_game_change;
$wait_game_change = AnyEvent::Run->new(
cmd => sub {
test_print();
print ''; #for correctly working
},
on_read => sub {
shift->push_read( line => sub {
warn 'read: ', $_[1];
});
},
on_eof => sub {
undef $wait_game_change;
$match_time_start->send;
},
);
$match_time_start->recv;
sub test_print {
sleep 3; #processed something
return [1,2,3];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment