1Mail::SpamAssassin::TimUesoeurt(C3o)ntributed Perl DocumMeanitla:t:iSopnamAssassin::Timeout(3)
2
3
4

NAME

6       Mail::SpamAssassin::Timeout - safe, reliable timeouts in perl
7

SYNOPSIS

9           # non-timeout code...
10
11           my $t = Mail::SpamAssassin::Timeout->new({ secs => 5 });
12
13           $t->run(sub {
14               # code to run with a 5-second timeout...
15           });
16
17           if ($t->timed_out()) {
18               # do something...
19           }
20
21           # more non-timeout code...
22

DESCRIPTION

24       This module provides a safe, reliable and clean API to provide
25       alarm(2)-based timeouts for perl code.
26
27       Note that $SIG{ALRM} is used to provide the timeout, so this will not
28       interrupt out-of-control regular expression matches.
29
30       Nested timeouts are supported.
31

PUBLIC METHODS

33       my $t = Mail::SpamAssassin::Timeout->new({ ... options ... });
34           Constructor.  Options include:
35
36           secs => $seconds
37               timeout, in seconds.  Optional; if not specified, no timeouts
38               will be applied.
39
40       $t->run($coderef)
41           Run a code reference within the currently-defined timeout.
42
43           The timeout is as defined by the secs parameter to the constructor.
44
45           Returns whatever the subroutine returns, or "undef" on timeout.  If
46           the timer times out, "$t-<gt"timed_out()> will return 1.
47
48           Time elapsed is not cumulative; multiple runs of "run" will restart
49           the timeout from scratch.
50
51       $t->run_and_catch($coderef)
52           Run a code reference, as per "$t-<gt"run()>, but also catching any
53           "die()" calls within the code reference.
54
55           Returns "undef" if no "die()" call was executed and $@ was unset,
56           or the value of $@ if it was set.  (The timeout event doesn't count
57           as a "die()".)
58
59       $t->timed_out()
60           Returns 1 if the most recent code executed in "run()" timed out, or
61           "undef" if it did not.
62
63       $t->reset()
64           If called within a "run()" code reference, causes the current alarm
65           timer to be reset to its starting value.
66
67
68
69perl v5.8.8                       2008-01-05    Mail::SpamAssassin::Timeout(3)
Impressum