Dave wrote:
> Still a bit too complex for my taste: perhaps we can use C<timeout> to
> generate exceptions:
> 
>   my lazy::threaded $result := { slow_fn_imp @_ };
>   loop {
>     timeout(60);
>     return $result;
>     CATCH Timeout { print "...$(time)\n" }
>  }
> 
> At last, no C<tid>! (Reminder: the suggested semantics of the threaded
> variable were that a FETCH to it blocks until the result of the thread is
> available).

To nitpick:

    my $result is lazy::threaded := { slow_fn_imp @_ };

Because lazy::threaded isn't the I<return> type, it's the I<variable>
type.

    loop {
        timeout(60);
        return $result;
        CATCH {
            when Timeout { print "...$(time)\n"
        }
    }

Because C<CATCH> is like C<given $!>.

I like that elegant use of threaded variables, by the way.

Now write the C<timeout> function :-P.

Luke

Reply via email to