Created
August 21, 2009 02:25
-
-
Save ryan5500/171604 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 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