… | |
… | |
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 | |
1220 | our %method = map +($_ => 1), |
1220 | our %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 | |
1223 | our @post_detect; |
1223 | our @post_detect; |
1224 | |
1224 | |
1225 | sub post_detect(&) { |
1225 | sub post_detect(&) { |
1226 | my ($cb) = @_; |
1226 | my ($cb) = @_; |
… | |
… | |
1739 | |
1739 | |
1740 | sub _send { |
1740 | sub _send { |
1741 | # nop |
1741 | # nop |
1742 | } |
1742 | } |
1743 | |
1743 | |
|
|
1744 | sub _wait { |
|
|
1745 | Carp::croak "$AnyEvent::MODEL does not support blocking waits. Caught"; |
|
|
1746 | } |
|
|
1747 | |
1744 | sub send { |
1748 | sub 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 | |
1756 | sub ready { |
1760 | sub ready { |
1757 | $_[0]{_ae_sent} |
1761 | $_[0]{_ae_sent} |
1758 | } |
1762 | } |
1759 | |
1763 | |
1760 | sub _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 | |
|
|
1769 | sub recv { |
1764 | sub 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 | |
1776 | sub cb { |
1781 | sub 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 | |
1803 | In general, AnyEvent does not do any error handling - it relies on the |
1808 | In general, AnyEvent does not do any error handling - it relies on the |
1804 | caller to do that if required. The L<AnyEvent::Strict> module (see also |
1809 | caller to do that if required. The L<AnyEvent::Strict> module (see also |