Re: Threads and Progress Monitors

2003-05-31 Thread Dulcimer
--- Dave Whipp <[EMAIL PROTECTED]> wrote: > Dulcimer wrote: > >>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... > > > > > > Maybe I'm being dense...

Re: Threads and Progress Monitors

2003-05-30 Thread Paul Johnson
Dave Whipp said: > I've just realised, however, that I'm relying on it being destroyed on > leaving the scope. I'm not sure that the GC guarentees that. GC doesn't, but I would be surprised if Perl 6 doesn't and in that case Parrot will be accommodating. Take a look at the recent p6i archives f

Re: Threads and Progress Monitors

2003-05-30 Thread Dave Whipp
Dulcimer wrote: 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... Maybe I'm being dense Why not just sub slow_fn { Timer.new(1, { print "." }); return slow_fn_imp @_;

Re: Threads and Progress Monitors

2003-05-30 Thread Dulcimer
> 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... Maybe I'm being dense Why not just sub slow_fn { Timer.new(1, { print "." }); return slow_fn_imp @_;

Re: Threads and Progress Monitors

2003-05-30 Thread Dave Whipp
"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

Re: Threads and Progress Monitors

2003-05-30 Thread Michael Lazzaro
On Thursday, May 29, 2003, at 04:48 PM, Luke Palmer wrote: To nitpick: my $result is lazy::threaded := { slow_fn_imp @_ }; Pursuing this lazy-threaded variables notion, a question. Given: sub slow_func is threaded {# me likey this auto-parallelizing syntax! ... }

Re: Threads and Progress Monitors

2003-05-30 Thread Michael Lazzaro
On Thursday, May 29, 2003, at 12:45 PM, Dave Whipp wrote: "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(

Re: Threads and Progress Monitors

2003-05-30 Thread Luke Palmer
Dave wrote: > Still a bit too complex for my taste: perhaps we can use C to > generate exceptions: > > my lazy::threaded $result := { slow_fn_imp @_ }; > loop { > timeout(60); > return $result; > CATCH Timeout { print "...$(time)\n" } > } > > At last, no C! (Reminder: the suggest

Re: Threads and Progress Monitors

2003-05-30 Thread Dave Whipp
"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

Re: Threads and Progress Monitors

2003-05-30 Thread John Macdonald
On Thu, May 29, 2003 at 10:47:35AM -0700, Dave Whipp wrote: > OK, we've beaten the producer/consumer thread/coro model to death. Here's a > different use of threads: how simple can we make this in P6: > > sub slow_func > { > my $percent_done = 0; > my $tid = thread { slow_f

Re: Threads and Progress Monitors

2003-05-30 Thread Dave Whipp
"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; >

Re: Threads and Progress Monitors

2003-05-30 Thread Michael Lazzaro
On Thursday, May 29, 2003, at 10:47 AM, Dave Whipp wrote: OK, we've beaten the producer/consumer thread/coro model to death. Here's a different use of threads: how simple can we make this in P6: Hey, good example. Hmm... Well, for starters I think it wouldn't be a big deal to associate a "prog

Re: Threads and Progress Monitors

2003-05-30 Thread Austin Hastings
--- Dave Whipp <[EMAIL PROTECTED]> wrote: > OK, we've beaten the producer/consumer thread/coro model to death. > Here's a > different use of threads: how simple can we make this in P6: > > sub slow_func > { > my $percent_done = 0; > my $tid = thread { slow_func_imp( \$perc