ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/EV.pm
(Generate patch)

Comparing EV/EV.pm (file contents):
Revision 1.54 by root, Tue Nov 27 07:27:10 2007 UTC vs.
Revision 1.57 by root, Wed Nov 28 17:32:24 2007 UTC

76 76
77@EV::IO::ISA = 77@EV::IO::ISA =
78@EV::Timer::ISA = 78@EV::Timer::ISA =
79@EV::Periodic::ISA = 79@EV::Periodic::ISA =
80@EV::Signal::ISA = 80@EV::Signal::ISA =
81@EV::Child::ISA =
82@EV::Stat::ISA =
81@EV::Idle::ISA = 83@EV::Idle::ISA =
82@EV::Prepare::ISA = 84@EV::Prepare::ISA =
83@EV::Check::ISA = 85@EV::Check::ISA =
84@EV::Child::ISA =
85@EV::Embed::ISA = 86@EV::Embed::ISA =
86@EV::Stat::ISA = "EV::Watcher"; 87@EV::Fork::ISA =
88 "EV::Watcher";
87 89
88=head1 BASIC INTERFACE 90=head1 BASIC INTERFACE
89 91
90=over 4 92=over 4
91 93
551watcher for all pids). 553watcher for all pids).
552 554
553=back 555=back
554 556
555 557
558=head3 STAT WATCHERS - did the file attributes just change?
559
560=over 4
561
562=item $w = EV::stat $path, $interval, $callback
563
564=item $w = EV::stat_ns $path, $interval, $callback
565
566Call the callback when a file status change has been detected on
567C<$path>. The C<$path> does not need to exist, changing from "path exists"
568to "path does not exist" is a status change like any other.
569
570The C<$interval> is a recommended polling interval for systems where
571OS-supported change notifications don't exist or are not supported. If
572you use C<0> then an unspecified default is used (which is highly
573recommended!), which is to be expected to be around five seconds usually.
574
575This watcher type is not meant for massive numbers of stat watchers,
576as even with OS-supported change notifications, this can be
577resource-intensive.
578
579The C<stat_ns> variant doesn't start (activate) the newly created watcher.
580
581=item ... = $w->stat
582
583This call is very similar to the perl C<stat> built-in: It stats (using
584C<lstat>) the path specified in the watcher and sets perls stat cache (as
585well as EV's idea of the current stat values) to the values found.
586
587In scalar context, a boolean is return indicating success or failure of
588the stat. In list context, the same 13-value list as with stat is returned
589(except that the blksize and blocks fields are not reliable).
590
591In the case of an error, errno is set to C<ENOENT> (regardless of the
592actual error value) and the C<nlink> value is forced to zero (if the stat
593was successful then nlink is guaranteed to be non-zero).
594
595See also the next two entries for more info.
596
597=item ... = $w->attr
598
599Just like C<< $w->stat >>, but without the initial stat'ing: this returns
600the values most recently detected by EV. See the next entry for more info.
601
602=item ... = $w->prev
603
604Just like C<< $w->stat >>, but without the initial stat'ing: this returns
605the previous set of values, before the change.
606
607That is, when the watcher callback is invoked, C<< $w->prev >> will be set
608to the values found I<before> a change was detected, while C<< $w->attr >>
609returns the values found leading to the change detection. The difference (if any)
610between C<prev> and C<attr> is what triggered the callback.
611
612If you did something to the filesystem object and do not want to trigger
613yet another change, you can call C<stat> to update EV's idea of what the
614current attributes are.
615
616=item $w->set ($path, $interval)
617
618Reconfigures the watcher, see the constructor above for details. Can be
619called at any time.
620
621=item $current_path = $w->path
622
623=item $old_path = $w->path ($new_path)
624
625Returns the previously set path and optionally set a new one.
626
627=item $current_interval = $w->interval
628
629=item $old_interval = $w->interval ($new_interval)
630
631Returns the previously set interval and optionally set a new one. Can be
632used to query the actual interval used.
633
634=back
635
636
556=head3 IDLE WATCHERS - when you've got nothing better to do... 637=head3 IDLE WATCHERS - when you've got nothing better to do...
557 638
558=over 4 639=over 4
559 640
560=item $w = EV::idle $callback 641=item $w = EV::idle $callback
646 727
647The C<check_ns> variant doesn't start (activate) the newly created watcher. 728The C<check_ns> variant doesn't start (activate) the newly created watcher.
648 729
649=back 730=back
650 731
651=head3 STAT WATCHERS - did the file stats just change?
652 732
653=over 4 733=head3 FORK WATCHERS - the audacity to resume the event loop after a fork
654 734
655=item $w = EV::stat $path, $interval, $callback 735Fork watchers are called when a C<fork ()> was detected. The invocation
736is done before the event loop blocks next and before C<check> watchers
737are being called, and only in the child after the fork.
656 738
657=item $w = EV::stat_ns $path, $interval, $callback 739=over 4
658 740
659Call the callback when a file status change has been detected on 741=item $w = EV::fork $callback
660C<$path>. The C<$path> does not need to exist, changing from "path exists"
661to "path does not exist" is a status change like any other.
662 742
663The C<$interval> is a recommended polling interval for systems where 743=item $w = EV::fork_ns $callback
664OS-supported change notifications don't exist or are not supported. If
665you use C<0> then an unspecified default is used (which is highly
666recommended!), which is to be expected to be around five seconds usually.
667 744
668This watcher type is not meant for massive numbers of stat watchers, 745Call the callback before the event loop is resumed in the child process
669as even with OS-supported change notifications, this can be 746after a fork.
670resource-intensive.
671 747
672The C<stat_ns> variant doesn't start (activate) the newly created watcher. 748The C<fork_ns> variant doesn't start (activate) the newly created watcher.
673
674=item $w->set ($path, $interval)
675
676Reconfigures the watcher, see the constructor above for details. Can be
677called at any time.
678
679=item $current_path = $w->path
680
681=item $old_path = $w->path ($new_path)
682
683Returns the previously set path and optionally set a new one.
684
685=item $current_interval = $w->interval
686
687=item $old_interval = $w->interval ($new_interval)
688
689Returns the previously set interval and optionally set a new one. Can be
690used to query the actual interval used.
691 749
692=back 750=back
693 751
694 752
695=head1 THREADS 753=head1 THREADS

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines