diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-02-25 16:02:50 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-02-25 16:08:21 -0600 |
commit | ba16d6dba5b368acea00de3acf16a0257c8a7f80 (patch) | |
tree | 55aaefb88592cd76726c11adc17e791aab00305a /lib/Select | |
parent | 05185117208787ae086ff32f7f187d35182a7f94 (diff) | |
download | select-retry-ba16d6dba5b368acea00de3acf16a0257c8a7f80.tar.gz select-retry-ba16d6dba5b368acea00de3acf16a0257c8a7f80.zip |
make the api more extensible
Diffstat (limited to 'lib/Select')
-rw-r--r-- | lib/Select/Retry.pm | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/Select/Retry.pm b/lib/Select/Retry.pm index 11a79e4..2cbcf1b 100644 --- a/lib/Select/Retry.pm +++ b/lib/Select/Retry.pm @@ -8,7 +8,10 @@ use Sub::Exporter -setup => { }; sub retry_select { - my ($mode, $timeout, @handles) = @_; + my $options = (@_ > 1 && ref($_[0]) eq 'HASH' + ? shift + : { mode => 'r' }); + my (@handles) = @_; my $got_winch; my $old_winch = $SIG{WINCH}; @@ -20,11 +23,11 @@ sub retry_select { my ($out, $eout); my ($in, $ein) = (_build_select_vec(@handles)) x 2; my $res; - if ($mode eq 'r') { - $res = select($out = $in, undef, $eout = $ein, $timeout); + if ($options->{mode} eq 'r') { + $res = select($out = $in, undef, $eout = $ein, $options->{timeout}); } else { - $res = select(undef, $out = $in, $eout = $ein, $timeout); + $res = select(undef, $out = $in, $eout = $ein, $options->{timeout}); } my $again = $!{EAGAIN} || $!{EINTR}; |