… | |
… | |
790 | =item $cb = $cv->cb ($cb->($cv)) |
790 | =item $cb = $cv->cb ($cb->($cv)) |
791 | |
791 | |
792 | This is a mutator function that returns the callback set and optionally |
792 | This is a mutator function that returns the callback set and optionally |
793 | replaces it before doing so. |
793 | replaces it before doing so. |
794 | |
794 | |
795 | The callback will be called when the condition becomes "true", i.e. when |
795 | The callback will be called when the condition becomes (or already was) |
796 | C<send> or C<croak> are called, with the only argument being the condition |
796 | "true", i.e. when C<send> or C<croak> are called (or were called), with |
797 | variable itself. Calling C<recv> inside the callback or at any later time |
797 | the only argument being the condition variable itself. Calling C<recv> |
798 | is guaranteed not to block. |
798 | inside the callback or at any later time is guaranteed not to block. |
799 | |
799 | |
800 | =back |
800 | =back |
801 | |
801 | |
802 | =head1 SUPPORTED EVENT LOOPS/BACKENDS |
802 | =head1 SUPPORTED EVENT LOOPS/BACKENDS |
803 | |
803 | |
… | |
… | |
1115 | |
1115 | |
1116 | BEGIN { AnyEvent::common_sense } |
1116 | BEGIN { AnyEvent::common_sense } |
1117 | |
1117 | |
1118 | use Carp (); |
1118 | use Carp (); |
1119 | |
1119 | |
1120 | our $VERSION = 4.881; |
1120 | our $VERSION = 4.901; |
1121 | our $MODEL; |
1121 | our $MODEL; |
1122 | |
1122 | |
1123 | our $AUTOLOAD; |
1123 | our $AUTOLOAD; |
1124 | our @ISA; |
1124 | our @ISA; |
1125 | |
1125 | |
… | |
… | |
1634 | Carp::croak $_[0]{_ae_croak} if $_[0]{_ae_croak}; |
1634 | Carp::croak $_[0]{_ae_croak} if $_[0]{_ae_croak}; |
1635 | wantarray ? @{ $_[0]{_ae_sent} } : $_[0]{_ae_sent}[0] |
1635 | wantarray ? @{ $_[0]{_ae_sent} } : $_[0]{_ae_sent}[0] |
1636 | } |
1636 | } |
1637 | |
1637 | |
1638 | sub cb { |
1638 | sub cb { |
1639 | $_[0]{_ae_cb} = $_[1] if @_ > 1; |
1639 | my $cv = shift; |
|
|
1640 | |
|
|
1641 | @_ |
|
|
1642 | and $cv->{_ae_cb} = shift |
|
|
1643 | and $cv->{_ae_sent} |
|
|
1644 | and (delete $cv->{_ae_cb})->($cv); |
|
|
1645 | |
1640 | $_[0]{_ae_cb} |
1646 | $cv->{_ae_cb} |
1641 | } |
1647 | } |
1642 | |
1648 | |
1643 | sub begin { |
1649 | sub begin { |
1644 | ++$_[0]{_ae_counter}; |
1650 | ++$_[0]{_ae_counter}; |
1645 | $_[0]{_ae_end_cb} = $_[1] if @_ > 1; |
1651 | $_[0]{_ae_end_cb} = $_[1] if @_ > 1; |