Skip to content

Instantly share code, notes, and snippets.

@deppp
Created October 10, 2009 00:00
Show Gist options
  • Save deppp/206443 to your computer and use it in GitHub Desktop.
Save deppp/206443 to your computer and use it in GitHub Desktop.
AnyEvent::CondVar 5.201
# see AnyEvent.pm for full source code
our $WAITING;
sub _wait {
$WAITING
and !$_[0]{_ae_sent}
and Carp::croak "AnyEvent::CondVar: recursive blocking wait detected";
local $WAITING = 1;
AnyEvent->one_event while !$_[0]{_ae_sent};
}
sub recv {
$_[0]->_wait;
Carp::croak $_[0]{_ae_croak} if $_[0]{_ae_croak};
wantarray ? @{ $_[0]{_ae_sent} } : $_[0]{_ae_sent}[0]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment