Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

io::async::file(3pm) [debian man page]

IO::Async::File(3pm)					User Contributed Perl Documentation				      IO::Async::File(3pm)

NAME
"IO::Async::File" - watch a file for changes SYNOPSIS
use IO::Async::File; use IO::Async::Loop; my $loop = IO::Async::Loop->new; my $file = IO::Async::File->new( filename => "config.ini", on_mtime_changed => sub { my ( $self ) = @_; print STDERR "Config file has changed "; reload_config( $self->handle ); } ); $loop->add( $file ); $loop->run; DESCRIPTION
This subclass of IO::Async::Notifier watches an open filehandle or named filesystem entity for changes in its "stat()" fields. It invokes various events when the values of these fields change. It is most often used to watch a file for size changes; for this task see also IO::Async::FileStream. While called "File", it is not required that the watched filehandle be a regular file. It is possible to watch anything that stat(2) may be called on, such as directories or other filesystem entities. EVENTS
The following events are invoked, either using subclass methods or CODE references in parameters. on_dev_changed $new_dev, $old_dev on_ino_changed $new_ino, $old_ino ... on_ctime_changed $new_ctime, $old_ctime Invoked when each of the individual "stat()" fields have changed. All the "stat()" fields are supported apart from "blocks" and "blksize". Each is passed the new and old values of the field. on_devino_changed $new_stat, $old_stat Invoked when either of the "dev" or "ino" fields have changed. It is passed two File::stat instances containing the complete old and new "stat()" fields. This can be used to observe when a named file is renamed; it will not be observed to happen on opened filehandles. on_stat_changed $new_stat, $old_stat Invoked when any of the "stat()" fields have changed. It is passed two File::stat instances containing the old and new "stat()" fields. PARAMETERS
The following named parameters may be passed to "new" or "configure". handle => IO The opened filehandle to watch for "stat()" changes if "filename" is not supplied. filename => STRING Optional. If supplied, watches the named file rather than the filehandle given in "handle". The file will be opened for reading and then watched for renames. If the file is renamed, the new filename is opened and tracked similarly after closing the previous file. interval => NUM Optional. The interval in seconds to poll the filehandle using stat(2) looking for size changes. A default of 2 seconds will be applied if not defined. METHODS
$handle = $file->handle Returns the filehandle currently associated with the instance; either the one passed to the "handle" parameter, or opened from the "filename" parameter. AUTHOR
Paul Evans <leonerd@leonerd.org.uk> perl v5.14.2 2012-10-24 IO::Async::File(3pm)

Check Out this Related Man Page

IO::Async::Loop::Poll(3pm)				User Contributed Perl Documentation				IO::Async::Loop::Poll(3pm)

NAME
"IO::Async::Loop::Poll" - use "IO::Async" with "poll(2)" SYNOPSIS
Normally an instance of this class would not be directly constructed by a program. It may however, be useful for runinng IO::Async with an existing program already using an "IO::Poll" object. use IO::Poll; use IO::Async::Loop::Poll; my $poll = IO::Poll->new; my $loop = IO::Async::Loop::Poll->new( poll => $poll ); $loop->add( ... ); while(1) { my $timeout = ... my $ret = $poll->poll( $timeout ); $loop->post_poll; } DESCRIPTION
This subclass of "IO::Async::Loop" uses an "IO::Poll" object to perform read-ready and write-ready tests. To integrate with existing code that uses an "IO::Poll", a "post_poll" can be called immediately after the "poll" method on the contained "IO::Poll" object. The appropriate mask bits are maintained on the "IO::Poll" object when notifiers are added or removed from the set, or when they change their "want_writeready" status. The "post_poll" method inspects the result bits and invokes the "on_read_ready" or "on_write_ready" methods on the notifiers. CONSTRUCTOR
$loop = IO::Async::Loop::Poll->new( %args ) This function returns a new instance of a "IO::Async::Loop::Poll" object. It takes the following named arguments: "poll" The "IO::Poll" object to use for notification. Optional; if a value is not given, a new "IO::Poll" object will be constructed. METHODS
$count = $loop->post_poll( $poll ) This method checks the returned event list from a "IO::Poll::poll" call, and calls any of the notification methods or callbacks that are appropriate. It returns the total number of callbacks that were invoked; that is, the total number of "on_read_ready" and "on_write_ready" callbacks for "watch_io", and "watch_time" event callbacks. $poll Reference to the "IO::Poll" object $count = $loop->loop_once( $timeout ) This method calls the "poll" method on the stored "IO::Poll" object, passing in the value of $timeout, and then runs the "post_poll" method on itself. It returns the total number of callbacks invoked by the "post_poll" method, or "undef" if the underlying "poll" method returned an error. AUTHOR
Paul Evans <leonerd@leonerd.org.uk> perl v5.14.2 2012-10-24 IO::Async::Loop::Poll(3pm)
Man Page