"Michael Lazzaro" <[EMAIL PROTECTED]> wrote in> # But if you want to get the thread object, so you can monitor it's
> { > ... > my $tid = thread &slow_func_impl(...); > while $tid.active { > status_monitor($tid.progress); > sleep 60; > } > return $tid.result; > } > > To my eye, that looks pretty darn slick. You might be a bit frustrated if the &slow_func_impl took 61 seconds :-(. How do we interrupt the C<sleep>? Possibly in the same way as we'd timeout a blocking IO operations. But I wonder if this could work: my $tid = thread &slow_func_impl(...); until wait $tid, timeout=>60 { status_monitor($tid.progress); } return $tid.result; Here I assume that C<wait> returns a true value if its waited condition occurs, but false if it times out. Hmm, A few days ago I tried indroducing a syntax for thread with a sensitivity list in place of an explict loop-forever thread. Perhaps I can reuse that syntax: my $tid = thread &slow_func_impl(...); thread $tid | timeout(60) { when $tid => { return $tid.result } default => { status_monitor $tid.progress } } Perhaps a different keyword would be better: C<always> as the looping counterpart to C<wait> -- then extend C<wait> to accept a code block. Dave.