a programming paradigm in which the flow of the program is determined by events—e.g., sensor outputs or user actions (mouse clicks, key presses) or messages from other programs or threads. ref: wikipedia 12年4月14日星期六
a programming paradigm in which the flow of the program is determined by events—e.g., sensor outputs or user actions (mouse clicks, key presses) or messages from other programs or threads. ref: wikipedia 12年4月14日星期六
AE::cv { say "START"; $working->send; }; $working = AE::cv { say "WORKING for 5s"; my $w; $w = AE::timer 5, 0, sub { say "DONE working."; $end->send; undef $w; } }; $end = AE::cv { say "END"; }; $start->send; $end->recv; State State Handlers 12年4月14日星期六
new AnyEvent::DBI "DBI:SQLite:dbname=test.db", "", ""; $dbh->exec("select * from orders where owner=?", "gugod", sub { my ($dbh, $rows, $rv) = @_; $#_ or die "failure: $@"; print "@$_\n" for @$rows; $cv->send; }); # asynchronously do sth. else here $cv->recv; 12年4月14日星期六