Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

cps::governor::deferred(3pm) [debian man page]

CPS::Governor::Deferred(3pm)				User Contributed Perl Documentation			      CPS::Governor::Deferred(3pm)

NAME
"CPS::Governor::Deferred" - iterate at some later point SYNOPSIS
use CPS qw( gkforeach ); use CPS::Governor::Deferred; my $gov = CPS::Governor::Deferred->new; gkforeach( $gov, [ 1 .. 10 ], sub { my ( $item, $knext ) = @_; print "A$item "; goto &$knext; }, sub {}, ); gkforeach( $gov, [ 1 .. 10 ], sub { my ( $item, $knext ) = @_; print "B$item "; goto &$knext; }, sub {}, ); $gov->flush; DESCRIPTION
This CPS::Governor allows the functions using it to delay their iteration until some later point when the containing program invokes it. This allows two main advantages: o CPU-intensive operations may be split apart and mixed with other IO operations o Multiple control functions may be executed in pseudo-parallel, interleaving iterations of each giving a kind of concurrency These are achieved by having the governor store a list of code references that need to be invoked, rather than invoking them immediately. These references can then be invoked later, perhaps by using an idle watcher in an event framework. Because each code reference hasn't yet been invoked by the time the "again" method is called, the original caller is free to store more pending references with the governor. This allows multiple control functions to be interleaved, as in the "A" and "B" example above. CONSTRUCTOR
$gov = CPS::Governor::Deferred->new( %args ) Returns a new instance of a "CPS::Governor::Deferred" object. Requires no parameters but may take any of the following to adjust its default behaviour: defer_after => INT If given some positive number, $n then the first "$n-1" invocations of the "again" method will in fact be executed immediately. Thereafter they will be enqueued in the normal mechanism. This gives the effect that longrunning loops will be executed in batches of $n. If not supplied then every invocation of "again" will use the queueing mechanism. METHODS
$pending = $gov->is_pending Returns true if at least one code reference has been stored that hasn't yet been invoked. $gov->prod Invokes all of the currently-stored code references, in the order they were stored. If any new references are stored by these, they will not yet be invoked, but will be available for the next time this method is called. $gov->flush Repeatedly calls "prod" until no more code references are pending. SUBCLASS METHODS
The following methods are used internally to implement the functionality, which may be useful to implementors of subclasses. $gov->later( $code, @args ) Used to enqueue the $code ref to be invoked later with the given @args, once it is determined this should be deferred (rather than being invoked immediately in the case of the first few invocations when "defer_after" is set). AUTHOR
Paul Evans <leonerd@leonerd.org.uk> perl v5.14.2 2012-06-27 CPS::Governor::Deferred(3pm)

Check Out this Related Man Page

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

NAME
"IO::Async::PID" - event callback on exit of a child process SYNOPSIS
use IO::Async::PID; use POSIX qw( WEXITSTATUS ); use IO::Async::Loop; my $loop = IO::Async::Loop->new; my $kid = $loop->fork( code => sub { print "Child sleeping.. "; sleep 10; print "Child exiting "; return 20; }, ); print "Child process $kid started "; my $pid = IO::Async::PID->new( pid => $kid, on_exit => sub { my ( $self, $exitcode ) = @_; printf "Child process %d exited with status %d ", $self->pid, WEXITSTATUS($exitcode); }, ); $loop->add( $pid ); $loop->run; DESCRIPTION
This subclass of IO::Async::Notifier invokes its callback when a process exits. For most use cases, a IO::Async::Process object provides more control of setting up the process, connecting filehandles to it, sending data to and receiving data from it. EVENTS
The following events are invoked, either using subclass methods or CODE references in parameters: on_exit $exitcode Invoked when the watched process exits. PARAMETERS
The following named parameters may be passed to "new" or "configure": pid => INT The process ID to watch. Must be given before the object has been added to the containing "IO::Async::Loop" object. on_exit => CODE CODE reference for the "on_exit" event. Once the "on_exit" continuation has been invoked, the "IO::Async::PID" object is removed from the containing "IO::Async::Loop" object. METHODS
$process_id = $pid->pid Returns the underlying process ID $pid->kill( $signal ) Sends a signal to the process AUTHOR
Paul Evans <leonerd@leonerd.org.uk> perl v5.14.2 2012-10-24 IO::Async::PID(3pm)
Man Page