Ramana Mokkapati > Sub-Timebound-1.01 > Sub::Timebound

Download:
Sub-Timebound-1.01.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.01   Source  

NAME ^

Sub::Timebound - Perl extension for timebound computations

SYNOPSIS ^

             use Sub::Timebound;

             sub fun 
             {
                my $i = shift;
                if ($i =~ /7$/) {
                        die "Simulated internal error\n";
                }
                while ($i) {
                        $i--;
                }
                return "All is well";
             }

             my $x = timeboundretry(10, 3, 5, \&fun, 10);
             ### Returns { value => '...', status => 0(FAILURE)/1(SUCCESS) }
             ### 'value' is the return value of fun()

             if ($x->{status}) {
                     # SUCCESS
                     $x->{value}
             } else {
                      # FAILURE
             }

DESCRIPTION ^

        Module exports "timeboundretry" - this is a wrapper that watches a function call.

        my $x = timeboundretry([TimeAllocated], [NumberOfAttempts], 
                        [PauseBetweenAttempts],[CodeRef],[Param1], [Param2], ...);


        [TimeAllocated]         - Seconds allocated to [CodeRef] to complete
        [NumberOfAttempts]      - Number of attempts made to [CodeRef]
        [PauseBetweenAttempts]  - Seconds to wait before making subsequent attempts
        [CodeRef]               - Reference to subroutine
        [Param1]...             - Parameters to subroutine

EXPORT

        timeboundretry()

SEE ALSO ^

        Proc::Reliable is a similar module that addresses external processes

AUTHOR ^

        Ramana Mokkapati, E<lt>mvr@cpan.org<gt>

COPYRIGHT AND LICENSE ^

        Copyright (C) 2005 by Ramana Mokkapati <mvr@cpan.org>

        This library is free software; you can redistribute it and/or modify
        it under the same terms as Perl itself, either Perl version 5.8.0 or,
        at your option, any later version of Perl 5 you may have available.
syntax highlighting: