Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub ae_run_seq {
- my $cv = AE::cv;
- my $continue_cb =
- ( is_refref($_[$#_]) and is_coderef(${$_[$#_]}) )
- ? ${pop @_}
- : sub { $_[0]->send };
- my @callbacks = @_;
- sub {
- my $cb = scalar(shift @callbacks);
- unless (! @callbacks or is_coderef($cb) ) {
- die 'all callbacks must be code references'
- }
- $cb and $cb->($cv, __SUB__) or $continue_cb->($cv)
- }->();
- $cv->recv;
- }
- sub ae_run_conc {
- my $cv = AE::cv;
- my $continue_cb = ( is_refref($_[$#_]) and is_coderef(${$_[$#_]}) ) ? ${pop @_} : undef;
- my $auto_end = sub { $cv->end };
- for my $callback ( @_ ) {
- $cv->begin;
- $callback->($cv, $auto_end);
- }
- $continue_cb and $continue_cb->($cv) or $cv->recv;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement