CPS
view release on metacpan or search on metacpan
kloop( \&body, $k )
gkloop( $gov, \&body, $k )
kforeach( \@items, \&body, $k )
gkforeach( $gov, \@items, \&body, $k )
etc...
In this way, other governor objects can be constructed which have
different running properties; such as interleaving iterations of their
loop with other IO activity in an event-driven framework, or giving
rate-limitation control on the speed of iteration of the loop.
CPS UTILITIES
These function names do not begin with k because they are not
themselves CPS primatives, but may be useful in CPS-oriented code.
$kfunc = liftk { BLOCK }
kloop( \&body, $k )
gkloop( $gov, \&body, $k )
kforeach( \@items, \&body, $k )
gkforeach( $gov, \@items, \&body, $k )
etc...
In this way, other governor objects can be constructed which have different
running properties; such as interleaving iterations of their loop with other
IO activity in an event-driven framework, or giving rate-limitation control on
the speed of iteration of the loop.
=cut
# The above is a lie. The basic functions provided are actually the gk*
# versions; we wrap these to make the normal k* functions by passing a simple
# governor.
sub _governate
{
lib/CPS/Governor.pm view on Meta::CPAN
=head1 NAME
C<CPS::Governor> - control the iteration of the C<CPS> functions
=head1 DESCRIPTION
Objects based on this abstract class are used by the C<gk*> variants of the
L<CPS> functions, to control their behavior. These objects are expected to
provide a method, C<again>, which the functions will use to re-invoke
iterations of loops, and so on. By providing a different implementation of
this method, governor objects can provide such behaviours as rate-limiting,
asynchronisation or parallelism, and integration with event-based IO
frameworks.
=cut
=head1 CONSTRUCTOR
=cut
lib/CPS/Governor/Deferred.pm view on Meta::CPAN
=over 4
=item *
CPU-intensive operations may be split apart and mixed with other IO operations
=item *
Multiple control functions may be executed in pseudo-parallel, interleaving
iterations of each giving a kind of concurrency
=back
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 C<again>
method is called, the original caller is free to store more pending references
( run in 0.861 second using v1.01-cache-2.11-cpan-96521ef73a4 )