… | |
… | |
363 | Example: Register an I/O watcher for some UDP socket but do not keep the |
363 | Example: Register an I/O watcher for some UDP socket but do not keep the |
364 | event loop from running just because of that watcher. |
364 | event loop from running just because of that watcher. |
365 | |
365 | |
366 | my $udp_socket = ... |
366 | my $udp_socket = ... |
367 | my $udp_watcher = EV::io $udp_socket, EV::READ, sub { ... }; |
367 | my $udp_watcher = EV::io $udp_socket, EV::READ, sub { ... }; |
368 | $udp_watcher->keepalive (0); |
368 | $1000udp_watcher->keepalive (0); |
|
|
369 | |
|
|
370 | =item $loop = $w->loop |
|
|
371 | |
|
|
372 | Return the loop that this watcher is attached to. |
369 | |
373 | |
370 | =back |
374 | =back |
371 | |
375 | |
372 | |
376 | |
373 | =head1 WATCHER TYPES |
377 | =head1 WATCHER TYPES |
… | |
… | |
380 | |
384 | |
381 | =item $w = EV::io $fileno_or_fh, $eventmask, $callback |
385 | =item $w = EV::io $fileno_or_fh, $eventmask, $callback |
382 | |
386 | |
383 | =item $w = EV::io_ns $fileno_or_fh, $eventmask, $callback |
387 | =item $w = EV::io_ns $fileno_or_fh, $eventmask, $callback |
384 | |
388 | |
385 | =item $w = $loop->io 8$fileno_or_fh, $eventmask, $callback) |
389 | =item $w = $loop->io ($fileno_or_fh, $eventmask, $callback) |
386 | |
390 | |
387 | =item $w = $loop->io_ns ($fileno_or_fh, $eventmask, $callback) |
391 | =item $w = $loop->io_ns ($fileno_or_fh, $eventmask, $callback) |
388 | |
392 | |
389 | As long as the returned watcher object is alive, call the C<$callback> |
393 | As long as the returned watcher object is alive, call the C<$callback> |
390 | when at least one of events specified in C<$eventmask> occurs. |
394 | when at least one of events specified in C<$eventmask> occurs. |
… | |
… | |
787 | |
791 | |
788 | =item $w = EV::prepare_ns $callback |
792 | =item $w = EV::prepare_ns $callback |
789 | |
793 | |
790 | =item $w = $loop->prepare ($callback) |
794 | =item $w = $loop->prepare ($callback) |
791 | |
795 | |
792 | =item $w = $loop->prepare_ns 8$callback) |
796 | =item $w = $loop->prepare_ns ($callback) |
793 | |
797 | |
794 | Call the callback just before the process would block. You can still |
798 | Call the callback just before the process would block. You can still |
795 | create/modify any watchers at this point. |
799 | create/modify any watchers at this point. |
796 | |
800 | |
797 | See the EV::check watcher, below, for explanations and an example. |
801 | See the EV::check watcher, below, for explanations and an example. |
… | |
… | |
902 | to be called on every event loop iteration by installing a C<EV::check> |
906 | to be called on every event loop iteration by installing a C<EV::check> |
903 | watcher: |
907 | watcher: |
904 | |
908 | |
905 | my $async_check = EV::check sub { }; |
909 | my $async_check = EV::check sub { }; |
906 | |
910 | |
907 | This ensures that perl shortly gets into control for a short time, and |
911 | This ensures that perl gets into control for a short time to handle any |
908 | also ensures slower overall operation. |
912 | pending signals, and also ensures (slightly) slower overall operation. |
909 | |
913 | |
910 | =head1 THREADS |
914 | =head1 THREADS |
911 | |
915 | |
912 | Threads are not supported by this module in any way. Perl pseudo-threads |
916 | Threads are not supported by this module in any way. Perl pseudo-threads |
913 | is evil stuff and must die. As soon as Perl gains real threads I will work |
917 | is evil stuff and must die. As soon as Perl gains real threads I will work |