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.349 by root, Mon Jul 4 21:14:42 2011 UTC vs.
Revision 1.350 by root, Tue Aug 2 20:02:44 2011 UTC

1216 [Cocoa::EventLoop:: => AnyEvent::Impl::Cocoa::], 1216 [Cocoa::EventLoop:: => AnyEvent::Impl::Cocoa::],
1217 [FLTK:: => AnyEvent::Impl::FLTK::], 1217 [FLTK:: => AnyEvent::Impl::FLTK::],
1218); 1218);
1219 1219
1220our %method = map +($_ => 1), 1220our %method = map +($_ => 1),
1221 qw(io timer time now now_update signal child idle condvar one_event DESTROY); 1221 qw(io timer time now now_update signal child idle condvar DESTROY);
1222 1222
1223our @post_detect; 1223our @post_detect;
1224 1224
1225sub post_detect(&) { 1225sub post_detect(&) {
1226 my ($cb) = @_; 1226 my ($cb) = @_;
1739 1739
1740sub _send { 1740sub _send {
1741 # nop 1741 # nop
1742} 1742}
1743 1743
1744sub _wait {
1745 Carp::croak "$AnyEvent::MODEL does not support blocking waits. Caught";
1746}
1747
1744sub send { 1748sub send {
1745 my $cv = shift; 1749 my $cv = shift;
1746 $cv->{_ae_sent} = [@_]; 1750 $cv->{_ae_sent} = [@_];
1747 (delete $cv->{_ae_cb})->($cv) if $cv->{_ae_cb}; 1751 (delete $cv->{_ae_cb})->($cv) if $cv->{_ae_cb};
1748 $cv->_send; 1752 $cv->_send;
1755 1759
1756sub ready { 1760sub ready {
1757 $_[0]{_ae_sent} 1761 $_[0]{_ae_sent}
1758} 1762}
1759 1763
1760sub _wait {
1761 $WAITING
1762 and !$_[0]{_ae_sent}
1763 and Carp::croak "AnyEvent::CondVar: recursive blocking wait detected";
1764
1765 local $WAITING = 1;
1766 AnyEvent->one_event while !$_[0]{_ae_sent};
1767}
1768
1769sub recv { 1764sub recv {
1765 unless ($_[0]{_ae_sent}) {
1766 $WAITING
1767 and Carp::croak "AnyEvent::CondVar: recursive blocking wait detected";
1768
1769 local $WAITING = 1;
1770 $_[0]->_wait; 1770 $_[0]->_wait;
1771 }
1771 1772
1772 Carp::croak $_[0]{_ae_croak} if $_[0]{_ae_croak}; 1773 $_[0]{_ae_croak}
1773 wantarray ? @{ $_[0]{_ae_sent} } : $_[0]{_ae_sent}[0] 1774 and Carp::croak $_[0]{_ae_croak};
1775
1776 wantarray
1777 ? @{ $_[0]{_ae_sent} }
1778 : $_[0]{_ae_sent}[0]
1774} 1779}
1775 1780
1776sub cb { 1781sub cb {
1777 my $cv = shift; 1782 my $cv = shift;
1778 1783
1794 &{ $_[0]{_ae_end_cb} || sub { $_[0]->send } }; 1799 &{ $_[0]{_ae_end_cb} || sub { $_[0]->send } };
1795} 1800}
1796 1801
1797# undocumented/compatibility with pre-3.4 1802# undocumented/compatibility with pre-3.4
1798*broadcast = \&send; 1803*broadcast = \&send;
1799*wait = \&_wait; 1804*wait = \&recv;
1800 1805
1801=head1 ERROR AND EXCEPTION HANDLING 1806=head1 ERROR AND EXCEPTION HANDLING
1802 1807
1803In general, AnyEvent does not do any error handling - it relies on the 1808In general, AnyEvent does not do any error handling - it relies on the
1804caller to do that if required. The L<AnyEvent::Strict> module (see also 1809caller to do that if required. The L<AnyEvent::Strict> module (see also

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines