Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Threads and Progress Monitors
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Austin Hastings  
View profile  
 More options May 29 2003, 2:48 pm
Newsgroups: perl.perl6.language
From: austin_hasti...@yahoo.com (Austin Hastings)
Date: Thu, 29 May 2003 11:31:00 -0700 (PDT)
Subject: Re: Threads and Progress Monitors

--- Dave Whipp <d...@whipp.name> 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( \$percent_done ) };
>           thread { status_monitor($percent_done) and sleep 60 until
> $tid.done };
>           return wait $tid;
>   }

> I think this would work under Austin's A17; but it feels a bit
> clunky. The
> fact that the "sleep 60" isn't broken as soon as the function is done
> is
> untidy, though I wouldn't want to start killing thread.

> perhaps:

>   {
>       ...
>       $tid = thread { slow... }
>       status_monitor(\$percent_done) and wait(60 | $tid) until
> $tid.done;
>       return $tid.result;
>   }

> The thing is, that "wait 60" probably can't work -- replace C<60>
> with
> C<$period>, and the semantics change. There are some obvious hacks
> that
> could work here: but is there a really nice solution. Ideally, we
> won't need
> the low level details such as C<$tid>

sub slow_func_imp {
  my $pct_done = 0;
  ...
  yield $pct_done++;   # Per my recent message
  ...

}

sub slow_func {
  my $tid := thread &slow_func_imp;

  status_monitor($tid.resume)
    while $tid.active;

}


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.