… | |
… | |
878 | AnyEvent::Impl::EventLib based on Event::Lib, leaks memory and worse. |
878 | AnyEvent::Impl::EventLib based on Event::Lib, leaks memory and worse. |
879 | AnyEvent::Impl::POE based on POE, very slow, some limitations. |
879 | AnyEvent::Impl::POE based on POE, very slow, some limitations. |
880 | AnyEvent::Impl::Irssi used when running within irssi. |
880 | AnyEvent::Impl::Irssi used when running within irssi. |
881 | AnyEvent::Impl::IOAsync based on IO::Async. |
881 | AnyEvent::Impl::IOAsync based on IO::Async. |
882 | AnyEvent::Impl::Cocoa based on Cocoa::EventLoop. |
882 | AnyEvent::Impl::Cocoa based on Cocoa::EventLoop. |
|
|
883 | AnyEvent::Impl::FLTK based on FLTK. |
883 | |
884 | |
884 | =item Backends with special needs. |
885 | =item Backends with special needs. |
885 | |
886 | |
886 | Qt requires the Qt::Application to be instantiated first, but will |
887 | Qt requires the Qt::Application to be instantiated first, but will |
887 | otherwise be picked up automatically. As long as the main program |
888 | otherwise be picked up automatically. As long as the main program |
… | |
… | |
1161 | |
1162 | |
1162 | BEGIN { AnyEvent::common_sense } |
1163 | BEGIN { AnyEvent::common_sense } |
1163 | |
1164 | |
1164 | use Carp (); |
1165 | use Carp (); |
1165 | |
1166 | |
1166 | our $VERSION = '5.31'; |
1167 | our $VERSION = '5.34'; |
1167 | our $MODEL; |
1168 | our $MODEL; |
1168 | |
1169 | |
1169 | our $AUTOLOAD; |
1170 | our $AUTOLOAD; |
1170 | our @ISA; |
1171 | our @ISA; |
1171 | |
1172 | |
… | |
… | |
1211 | [POE::Kernel:: => AnyEvent::Impl::POE::], # lasciate ogni speranza |
1212 | [POE::Kernel:: => AnyEvent::Impl::POE::], # lasciate ogni speranza |
1212 | [Wx:: => AnyEvent::Impl::POE::], |
1213 | [Wx:: => AnyEvent::Impl::POE::], |
1213 | [Prima:: => AnyEvent::Impl::POE::], |
1214 | [Prima:: => AnyEvent::Impl::POE::], |
1214 | [IO::Async::Loop:: => AnyEvent::Impl::IOAsync::], |
1215 | [IO::Async::Loop:: => AnyEvent::Impl::IOAsync::], |
1215 | [Cocoa::EventLoop:: => AnyEvent::Impl::Cocoa::], |
1216 | [Cocoa::EventLoop:: => AnyEvent::Impl::Cocoa::], |
|
|
1217 | [FLTK:: => AnyEvent::Impl::FLTK::], |
1216 | ); |
1218 | ); |
1217 | |
1219 | |
1218 | our %method = map +($_ => 1), |
1220 | our %method = map +($_ => 1), |
1219 | 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); |
1220 | |
1222 | |
1221 | our @post_detect; |
1223 | our @post_detect; |
1222 | |
1224 | |
1223 | sub post_detect(&) { |
1225 | sub post_detect(&) { |
1224 | my ($cb) = @_; |
1226 | my ($cb) = @_; |
… | |
… | |
1737 | |
1739 | |
1738 | sub _send { |
1740 | sub _send { |
1739 | # nop |
1741 | # nop |
1740 | } |
1742 | } |
1741 | |
1743 | |
|
|
1744 | sub _wait { |
|
|
1745 | Carp::croak "$AnyEvent::MODEL does not support blocking waits. Caught"; |
|
|
1746 | } |
|
|
1747 | |
1742 | sub send { |
1748 | sub send { |
1743 | my $cv = shift; |
1749 | my $cv = shift; |
1744 | $cv->{_ae_sent} = [@_]; |
1750 | $cv->{_ae_sent} = [@_]; |
1745 | (delete $cv->{_ae_cb})->($cv) if $cv->{_ae_cb}; |
1751 | (delete $cv->{_ae_cb})->($cv) if $cv->{_ae_cb}; |
1746 | $cv->_send; |
1752 | $cv->_send; |
… | |
… | |
1753 | |
1759 | |
1754 | sub ready { |
1760 | sub ready { |
1755 | $_[0]{_ae_sent} |
1761 | $_[0]{_ae_sent} |
1756 | } |
1762 | } |
1757 | |
1763 | |
1758 | sub _wait { |
|
|
1759 | $WAITING |
|
|
1760 | and !$_[0]{_ae_sent} |
|
|
1761 | and Carp::croak "AnyEvent::CondVar: recursive blocking wait detected"; |
|
|
1762 | |
|
|
1763 | local $WAITING = 1; |
|
|
1764 | AnyEvent->one_event while !$_[0]{_ae_sent}; |
|
|
1765 | } |
|
|
1766 | |
|
|
1767 | 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; |
1768 | $_[0]->_wait; |
1770 | $_[0]->_wait; |
|
|
1771 | } |
1769 | |
1772 | |
1770 | Carp::croak $_[0]{_ae_croak} if $_[0]{_ae_croak}; |
1773 | $_[0]{_ae_croak} |
1771 | 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] |
1772 | } |
1779 | } |
1773 | |
1780 | |
1774 | sub cb { |
1781 | sub cb { |
1775 | my $cv = shift; |
1782 | my $cv = shift; |
1776 | |
1783 | |
… | |
… | |
1792 | &{ $_[0]{_ae_end_cb} || sub { $_[0]->send } }; |
1799 | &{ $_[0]{_ae_end_cb} || sub { $_[0]->send } }; |
1793 | } |
1800 | } |
1794 | |
1801 | |
1795 | # undocumented/compatibility with pre-3.4 |
1802 | # undocumented/compatibility with pre-3.4 |
1796 | *broadcast = \&send; |
1803 | *broadcast = \&send; |
1797 | *wait = \&_wait; |
1804 | *wait = \&recv; |
1798 | |
1805 | |
1799 | =head1 ERROR AND EXCEPTION HANDLING |
1806 | =head1 ERROR AND EXCEPTION HANDLING |
1800 | |
1807 | |
1801 | 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 |
1802 | 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 |