GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  ANYEVENT::WORKER (3)

.ds Aq ’

NAME

AnyEvent::Worker - Manage blocking task in external process

CONTENTS

SYNOPSIS



    use AnyEvent 5;
    use AnyEvent::Worker;
   
    my $worker1 = AnyEvent::Worker->new( [ Actual::Worker::Class => @init_args ] );
    my $worker2 = AnyEvent::Worker->new( sub { return "Cb 1 @_"; } );
    my $worker3 = AnyEvent::Worker->new( {
        class   => Actual::Worker::Class2,
        new     => create, # alternative constructor
        args    => [qw(arg1 arg2)],
    } );
   
    # Invoke method `test on Actual::Worker::Class with arguments @args
    $worker1->do( test => @args , sub {
        return warn "Request died: $@" if $@;
        warn "Received response: @_";
    });
   
    # Just call callback, passed to worker2 with arguments @args
    $worker2->do( @args , sub {
        return warn "Request died: $@" if $@;
        warn "Received response: @_";
    });



CONSTRUCTOR

new CW$cb->($req), CW%args

Simple stateless worker. On any do a sub sill be invoked with do arguments

new [ Class => CW@new_args ], CW%args

Stateful, object-based worker. After fork, Class will we used, then instantiated with new(@new_args).

First argument to do will be interpreted as object method, rest — as method arguments.

new { class => ’Class’, args => \@new_args, new => ’constructor_method’ }, CW%args

Same as previous, but allow to pass optional constructor name in new arg

CW$args{on_error} = CW$cb->($worker,$error,$fatal,$file,$line)

When an unexpected error occurs (for ex: child process exited or killed) on_error callback will be invoked

METHODS

do CW@args, CW$cb->($res)

Only for stateless worker.

do method => CW@args, CW$cb->($res)

Only for stateful worker.

METHODS

$worker->on_error ($cb->($worker, $filename, $line, $fatal)) Sets (or clears, with undef) the on_error handler.
$worker->timeout ($seconds) Sets (or clears, with undef) the database timeout. Useful to extend the timeout when you are about to make a really long query.
$worker->do ( @args, $cb->( $worker, @response ) ) Executes worker code and execure the callback, when response is ready

AUTHOR

Mons Anderson, <mons@cpan.org>

ACKNOWLEDGEMENTS

This module based on Marc Lehmann’s AnyEvent::DBI

Thanks to Vladimir Timofeev <vovkasm@cpan.org> for bugfixes and useful notes

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 ANYEVENT::WORKER (3) 2011-09-23

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.