Name : perl-Sys-AlarmCall
| |
Version : 1.2
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : lp154.7.1
| Date : 2023-01-27 18:11:51
|
Group : Development/Libraries/Perl
| Source RPM : perl-Sys-AlarmCall-1.2-lp154.7.1.src.rpm
|
Size : 0.01 MB
| |
Packager : https://www_suse_com/
| |
Summary : Sys::AlarmCall Perl module
|
Description :
Sys::AlarmCall provides a straightforward function call to use the alarm handler. It also handles the logic which allows nested time out calls if timeout calls are run thorugh the alarm_call() functions.
The main advantages of Sys::AlarmCall are that:
1. simple calls, e.g.
AATTresult = &func(AATTargs); #Normal function call with \'&\' $result = func(AATTargs);; #Normal function call AATTresult = &$code_reference(AATTargs); AATTresult = $obj->func(AATTargs); #Object method call
become simple calls:
AATTresult = alarm_call($timeout,\'&func\',AATTargs); $result = alarm_call($timeout,\'func\',AATTargs); AATTresult = alarm_call($timeout,$code_reference,AATTargs); AATTresult = alarm_call($timeout,\'->func\',$obj,AATTargs);
no need to futz around with alarms and handlers and worrying about where to intercept the timer or set globals or whatever; and
2. No need to worry if some subroutines within the call also set a timeout - all that is handled logically by the Sys::AlarmCall package (as long as the subroutines also use the alarm_call function of course. But if they don\'t you\'re up the same creek anyway).
Sys::AlarmCall exports one function,
* alarm_call TIMEOUT,FUNCTION,ARGS
Where TIMEOUT is a positive number (a fatal error occurs if TIMEOUT is not at least one);
FUNCTION is a string giving the function name (and the \'&\' if wanted, or preceded by \'->\', e.g. \'->func\', if using that, in which case the calling object should be the first argument in ARGS); and ARGS is the list of arguments to that function.
NOTE: As a side effect, normally fatal errors in the FUNCTION call are caught and reported in the return.
In a scalar context, returns as follows:
If the FUNCTION produces any sort of error (including fatal \'die\'s which are trapped), returns the error as a string, prepended by the value given by the variable $Sys::AlarmCall::SCALAR_ERROR (default is \'ERROR \').
If the FUNCTION times out (i.e. doesn\'t return before TIMEOUT - 1), returns the value given by the variable $Sys::AlarmCall::TIMEOUT (default is \'TIMEOUT\').
Otherwise, returns the scalar that the FUNCTION returns.
In an array context, returns as follows:
If the FUNCTION produces any sort of error (including fatal \'die\'s which are trapped), returns a two element array, the first element being the value given by the variable $Sys::AlarmCall::ARRAY_ERROR (default is \'ERROR\'), and the second element the error string produced.
If the FUNCTION times out (i.e. doesn\'t return before TIMEOUT - 1), returns a one element array consisting of the value given by the variable $Sys::AlarmCall::TIMEOUT (default is \'TIMEOUT\').
Otherwise, returns the array that the FUNCTION returns.
Specific support for the -> construct has been added to alarm_call, so that calling
alarm_call($timeout,\'->func\',$obj,AATTargs);
means that alarm_call will translate this to
$obj->func(AATTargs);
Specific support for code references (e.g. $ref = sub {warn \"this\ \"}) has been added to alarm_call, so that calling
alarm_call($timeout,$ref,AATTargs);
means that alarm_call will translate this to
&{$ref}(AATTargs);
Timers have resolutions of one second, but remember that a timeout value of 15 will cause a timeout to occur at some point more than 14 seconds in the future. (see alarm() function in perl man page). Also, nested calls decrease the resolution (make the uncertain interval larger) by one second per nesting depth. This is because an alarm call returns the time left rounded up to the next second.
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-S/15.4/noarch |