SPUG: Pull out of a blocking subroutine?
Skylos
skylos at gmail.com
Mon Jan 11 17:31:41 PST 2010
Sure.
http://www.sdsc.edu/~moreland/courses/IntroPerl/docs/manual/pod/perlfunc/alarm.html
eval {
local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required
alarm $timeout;
$nread = sysread SOCKET, $buffer, $size;
alarm 0;
};
if ($@) {
die unless $@ eq "alarm\n"; # propagate unexpected errors
# timed out
}
else {
# didn't
}
Skylos
"If only I could get rid of hunger by rubbing my belly" - Diogenes
On Mon, Jan 11, 2010 at 5:27 PM, Christopher Howard <choward at indicium.us>wrote:
> Hi. I'm still working on integrating LEGO::NXT into my project. Problem
> I've hit though is that apparently there are no actual functions for
> checking communication status with the robot.
>
> There is other function I thought I could use to detect (implicitly) if
> communication is still established. Problem is that they are /all/
> blocking. Documentation basically says that the author hasn't got around
> to making non-blocking functions yet, and I don't really have time to
> reprogram his module myself.
>
> So, my perverted, evil question: Is there some hackish way to pull out
> of a blocking subroutine? Say, if it has returned after three seconds or
> something like that?
>
> --
> Christopher Howard
> http://indicium.us
> http://theologia.indicium.us
> http://robots.arsc.edu
>
>
> _____________________________________________________________
> Seattle Perl Users Group Mailing List
> POST TO: spug-list at pm.org
> SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list
> MEETINGS: 3rd Tuesdays
> WEB PAGE: http://seattleperl.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/spug-list/attachments/20100111/bf783e96/attachment.html>
More information about the spug-list
mailing list