NAME

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

VERSION

version 0.02

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.