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.345 by root, Fri Dec 31 04:50:44 2010 UTC vs.
Revision 1.350 by root, Tue Aug 2 20:02:44 2011 UTC

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
886Qt requires the Qt::Application to be instantiated first, but will 887Qt requires the Qt::Application to be instantiated first, but will
887otherwise be picked up automatically. As long as the main program 888otherwise be picked up automatically. As long as the main program
1151 1152
1152package AnyEvent; 1153package AnyEvent;
1153 1154
1154# basically a tuned-down version of common::sense 1155# basically a tuned-down version of common::sense
1155sub common_sense { 1156sub common_sense {
1156 # from common:.sense 3.3 1157 # from common:.sense 3.4
1157 ${^WARNING_BITS} ^= ${^WARNING_BITS} ^ "\x3c\x3f\x33\x00\x0f\xf3\x0f\xc0\xf0\xfc\x33\x00"; 1158 ${^WARNING_BITS} ^= ${^WARNING_BITS} ^ "\x3c\x3f\x33\x00\x0f\xf0\x0f\xc0\xf0\xfc\x33\x00";
1158 # use strict vars subs - NO UTF-8, as Util.pm doesn't like this atm. (uts46data.pl) 1159 # use strict vars subs - NO UTF-8, as Util.pm doesn't like this atm. (uts46data.pl)
1159 $^H |= 0x00000600; 1160 $^H |= 0x00000600;
1160} 1161}
1161 1162
1162BEGIN { AnyEvent::common_sense } 1163BEGIN { AnyEvent::common_sense }
1163 1164
1164use Carp (); 1165use Carp ();
1165 1166
1166our $VERSION = '5.3'; 1167our $VERSION = '5.34';
1167our $MODEL; 1168our $MODEL;
1168 1169
1169our $AUTOLOAD; 1170our $AUTOLOAD;
1170our @ISA; 1171our @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
1218our %method = map +($_ => 1), 1220our %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
1221our @post_detect; 1223our @post_detect;
1222 1224
1223sub post_detect(&) { 1225sub post_detect(&) {
1224 my ($cb) = @_; 1226 my ($cb) = @_;
1737 1739
1738sub _send { 1740sub _send {
1739 # nop 1741 # nop
1740} 1742}
1741 1743
1744sub _wait {
1745 Carp::croak "$AnyEvent::MODEL does not support blocking waits. Caught";
1746}
1747
1742sub send { 1748sub 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
1754sub ready { 1760sub ready {
1755 $_[0]{_ae_sent} 1761 $_[0]{_ae_sent}
1756} 1762}
1757 1763
1758sub _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
1767sub 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;
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
1774sub cb { 1781sub 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
1801In 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
1802caller 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