AnyEvent-Gearman-WorkerPool

 view release on metacpan or  search on metacpan

lib/AnyEvent/Gearman/WorkerPool/Worker.pm  view on Meta::CPAN

    $self->unregister() if $self->worker;
    DEBUG __PACKAGE__." DEMOLISHED";
}

# class member
sub Loop{

    my $class = shift;
    die 'Use like PACKAGE->Loop(%opts).' unless $class;
    die 'You need to use your own class extending '. __PACKAGE__ .'!' if $class eq __PACKAGE__;
    my %opt = @_;

    my $cv = AE::cv;

    
    my $worker;
    my $sig = AE::signal INT=>sub{
        $worker->stop_safe('SIGINT');
        $cv->send;
    };

    $cv->begin(sub{ $cv->send; });
    eval{
        $worker = $class->new(%opt,cv=>$cv);
    };
    $cv->end;

    $cv->recv;
    DEBUG "stop completely";
}


1;

__END__

=pod

=encoding UTF-8

=head1 NAME

AnyEvent::Gearman::WorkerPool::Worker - A worker launched by Slot

=head1 VERSION

version 1.0

=head1 SYNOPSIS

make TestWorker.pm

    package TestWorker;
    use Any::Moose;
    extends 'AnyEvent::Gearman::WorkerPool::Worker';

    sub slowreverse{
        DEBUG 'slowreverse';
        my $self = shift;
        my $job = shift;
        my t = AE::timer 1,0, sub{
            my $res = reverse($job->workload);
            $job->complete( $res );
        };
    }
    sub reverse{
        my $self = shift;
        my $job = shift;
        my $res = reverse($job->workload);
        $job->complete( $res );
    }
    sub _private{
        my $self = shift;
        my $job = shift;
        $job->complete();
    }

You can see only 'reverse'

=head1 AUTHOR

HyeonSeung Kim <sng2nara@hanmail.net>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by HyeonSeung Kim.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut



( run in 0.832 second using v1.01-cache-2.11-cpan-5623c5533a1 )