ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/lib/AnyEvent.pm
(Generate patch)

Comparing AnyEvent/lib/AnyEvent.pm (file contents):
Revision 1.268 by root, Thu Jul 30 16:39:19 2009 UTC vs.
Revision 1.271 by root, Wed Aug 5 20:50:27 2009 UTC

790=item $cb = $cv->cb ($cb->($cv)) 790=item $cb = $cv->cb ($cb->($cv))
791 791
792This is a mutator function that returns the callback set and optionally 792This is a mutator function that returns the callback set and optionally
793replaces it before doing so. 793replaces it before doing so.
794 794
795The callback will be called when the condition becomes "true", i.e. when 795The callback will be called when the condition becomes (or already was)
796C<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
797variable itself. Calling C<recv> inside the callback or at any later time 797the only argument being the condition variable itself. Calling C<recv>
798is guaranteed not to block. 798inside 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
1116BEGIN { AnyEvent::common_sense } 1116BEGIN { AnyEvent::common_sense }
1117 1117
1118use Carp (); 1118use Carp ();
1119 1119
1120our $VERSION = 4.9; 1120our $VERSION = 4.901;
1121our $MODEL; 1121our $MODEL;
1122 1122
1123our $AUTOLOAD; 1123our $AUTOLOAD;
1124our @ISA; 1124our @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
1638sub cb { 1638sub 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
1643sub begin { 1649sub 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;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines