From ba16d6dba5b368acea00de3acf16a0257c8a7f80 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 25 Feb 2012 16:02:50 -0600 Subject: make the api more extensible --- lib/Select/Retry.pm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/Select/Retry.pm') 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}; -- cgit v1.2.3-54-g00ecf