NAME

CTK::Timeout - Provides execute the code reference wrapped with timeout

VERSION

Version 1.00

SYNOPSIS

use CTK::Timeout;

# Create the timeout object
my $to = CTK::Timeout->new();

# Execute
unless ($to->timeout_call(sub { sleep 2 } => 1)) {
    die $to->error if $to->error;
}

DESCRIPTION

This class provides execute the code reference wrapped with timeout

new

Creates the timeout object

my $to = CTK::Timeout->new();

Creates the timeout object without the POSIX "sigaction" supporting (forced off)

my $to = CTK::Timeout->new(0);

error

die $to->error if $to->error;

Returns error string

timeout_call

Given a code reference (with optional arguments @args) will execute as eval-wrapped with a timeout value (in seconds). This method returns the return-value of the specified code in scalar context

my $retval = $to->timeout_call(sub { sleep 2 } => 1, "foo", "bar");

HISTORY

See Changes file

DEPENDENCIES

POSIX, Config

TO DO

See TODO file

SEE ALSO

"Timeout" in DBI, Sys::SigAction

AUTHOR

Serż Minus (Sergey Lepenkov) https://www.serzik.com <abalama@cpan.org>

COPYRIGHT

Copyright (C) 1998-2022 D&D Corporation. All Rights Reserved

LICENSE

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

See LICENSE file and https://dev.perl.org/licenses/