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::Protocol(3pm)				User Contributed Perl Documentation				  IO::Async::Protocol(3pm)

NAME
"IO::Async::Protocol" - base class for transport-based protocols DESCRIPTION
This subclass of IO::Async:Notifier provides storage for a IO::Async::Handle object, to act as a transport for some protocol. It contains an instance of the transport object, which it adds as a child notifier, allowing a level of independence from the actual transport being used. For example, a stream may actually be an IO::Async::SSLStream to allow the protocol to be used over SSL. This class is not intended to be used directly, instead, see one of the subclasses IO::Async::Protocol::Stream - base class for stream-based protocols EVENTS
The following events are invoked, either using subclass methods or CODE references in parameters: on_closed Optional. Invoked when the transport handle becomes closed. PARAMETERS
The following named parameters may be passed to "new" or "configure": transport => IO::Async::Handle The "IO::Async::Handle" to delegate communications to. on_closed => CODE CODE reference for the "on_closed" event. When a new "transport" object is given, it will be configured by calling the "setup_transport" method, then added as a child notifier. If a different transport object was already configured, this will first be removed and deconfigured using the "teardown_transport". METHODS
$transport = $protocol->transport Returns the stored transport object $protocol->connect( %args ) Sets up a connection to a peer, and configures the underlying "transport" for the Protocol. Takes the following named arguments: socktype => STRING or INT Required. Identifies the socket type, and the type of continuation that will be used. If this value is "stream" or "SOCK_STREAM" then "on_stream" continuation will be used; otherwise "on_socket" will be used. on_connected => CODE Optional. If supplied, will be invoked once the connection has been established. $on_connected->( $protocol ) transport => IO::Async::Handle Optional. If this is provided, it will immediately be configured as the transport (by calling "configure"), and the "on_connected" callback will be invoked. This is provided as a convenient shortcut. Other arguments will be passed to the underlying "IO::Async::Loop" "connect" call. TRANSPORT DELEGATION
The following methods are delegated to the transport object close SUBCLASS METHODS
"IO::Async::Protocol" is a base class provided so that specific subclasses of it provide more specific behaviour. The base class provides a number of methods that subclasses may wish to override. If a subclass implements any of these, be sure to invoke the superclass method at some point within the code. $protocol->setup_transport( $transport ) Called by "configure" when a new "transport" object is given, this method should perform whatever setup is required to wire the new transport object into the protocol object; typically by setting up event handlers. $protocol->teardown_transport( $transport ) The reverse of "setup_transport"; called by "configure" when a previously set-up transport object is about to be replaced. AUTHOR
Paul Evans <leonerd@leonerd.org.uk> perl v5.14.2 2012-10-24 IO::Async::Protocol(3pm)
Man Page