"Luke Palmer" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>     my $result is lazy::threaded := { slow_fn_imp @_ };
>     loop {
>         timeout(60);
>         return $result;
>         CATCH {
>             when Timeout { print "...$(time)\n"
>         }
>     }
>
> Now write the C<timeout> function :-P.


Well, the obvious is

{
  temp %SIG{ALRM} = { print "..."; alarm(60) }
  alarm(60);
  LAST {alarm(0) };
  return $result;
}

Needless to say, I don't like that. But the good thing now is that I don't
need the loop. Now, if we had some form of Parrot-level signaling (instead
of OS-level); and if we had resumable exceptions; then perhaps I'd be able
to write

sub slow_fn {
   my $tick = Timer.new(60);
   CATCH { when $tick => { print "..."; continue } }
   return slow_fn_imp @_ ;
}

I think this hides the threads pretty effectively. Is a parrot-level timer
to much to ask for? How about resumable exceptions? But perhaps I'm still
being too clever, when a simpler solution exists:

sub slow_fn {
   my $tick = Timer.new(60, { print "..." });
   return slow_fn_imp @_;
}

Now if I could just get the compiler to not complain about that unused
variable...


Dave.


Reply via email to