Jonathan Rockway > AnyEvent-Retry > AnyEvent::Retry::Coro

Download:
AnyEvent-Retry-0.03.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Module Version: 0.03   Source  

NAME ^

AnyEvent::Retry::Coro - AnyEvent::Retry for jobs that run in separate threads

VERSION ^

version 0.03

SYNOPSIS ^

    use Coro;

    my $r = AnyEvent::Retry::Coro->new(
        max_tries => 100, # eventually give up
        interval  => { Constant => { interval => 1 } }, # try every second
        try       => {
            die 'out of cake!' if $cake-- < 0;
            return do_science();
        },

    );

    my $neat_gun = $r->run; # keep on trying until you run out of cake

DESCRIPTION ^

This module makes AnyEvent::Retry work nicely with Coro. You don't need to provide success or failure callbacks anymore, and your task to retry just needs die or return a result.

METHODS ^

run

This runs the task, blocking the thread until a result is available. If your task encounters an error, this will die. If it's sucessful, it returns the result.

wait

Allows you to run the task without blocking:

    $r->start;
    ...; # do anything
    my $result = $r->wait; # block here

run is implemented exactly like the above.

AUTHOR ^

Jonathan Rockway <jrockway@cpan.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2010 by Jonathan Rockway.

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

syntax highlighting: