"John Macdonald" <[EMAIL PROTECTED]> wrote > At first glance, this doesn't need a thread - a > Instead of > sleep, though, I'd use a pipeline and read it with > a non-blocking read until there is no data. ...
++ For the lateral thinking. Definitely a valid solution to the problem, as given. So I'll change the problem prevent it: the slow fn is a 3rd-party blob with no access to source code and no progress indication. sub slow_fn { print "starting slow operation: this sometimes takes half an hour!\n"; my $tid = thread { slow_fn_imp @_ }; $start = time; loop { wait $tid | timeout(60); return $tid.result if $tid.done; print "... $(time-$start) seconds\n"; } } 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). Dave.