Re: [groovy-user] GPars: guarded receive possible?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: [groovy-user] GPars: guarded receive possible?

Russel Winder-2
Bob,

Once the Gant 1.9.x release series is sorted (1.9.1 is released but no
feedback as yet) I will be more or less be "orphaning" Gant.  This will
allow me time to work on GPars.  The goal is to create a CSP
implementation for GPars.  Jon Kerridge did some work on Groovy CSP a
couple of years ago and the intention is to investigate integrate that
into GPars rather than just starting again from scratch.  The issue is
whether Peter Welch's JCSP is the best foundational tool or whether a
new start is best.

Sarah Mount has been developing Python-CSP and there are many lessons to
be learnt from there as well.

So all in all GPars doesn't yet have the sophistication and beauty of
CSP on offer.

On Sat, 2010-01-02 at 14:39 +1000, Bob Brown wrote:

> In Occam (truly a great language, teary sigh) I could write something like
> this (slightly clumsy) code:
>
> VAR enabled := TRUE
> VAR data
> CHAN data.chan
> CHAN control.chan
> ALT
>   enabled & data.chan ? data
>     -- do something with data
>   NOT enabled & control.chan ? ANY
>     enabled := TRUE
>   enabled & control.chan ? ANY
>     enabled := FALSE
>
> How can I have guarded receives with GPARS?
>
> NB this is NOT the same, since it involves consumption of a message:
>
> def enabled = false
> Actors.actor {
>   receive { msg ->
>     if (enabled) {
>       // do something with msg              
>     }
>   }
> }.start()
>
> Is this correct?
>
> def enabled = false
> Actors.actor {
>   if (enabled) {
>     receive { msg ->
>       // do something with msg              
>     }
>   }
> }.start()
>
> But I'm still struggling to see how alternation is handled...
>
> Ruby's stage library (http://sillito.ca/stage) has:
>
> while :done != receive(timeout) {|alt, msg|
>       alt.call(:assert, :_) {|t, conf, from, value|
>           self.when(certain?() && value == @value)
>           deny(from, value) }
>
>       alt.call(:assert, :_) {|t, conf, from, value|
>           self.when(value == @value && @confidence < conf)
>           new_value()
>           cede(from, value) }
>
> end
>
> Pointers gratefully accepted!
>
> Cheers and a Groovy New Year to all,
>
> BOB
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>

--
Russel.
=============================================================================
Dr Russel Winder      Partner
                                            xmpp: [hidden email]
Concertant LLP        t: +44 20 7585 2200, +44 20 7193 9203
41 Buckmaster Road,   f: +44 8700 516 084   voip: sip:[hidden email]
London SW11 1EN, UK   m: +44 7770 465 077   skype: russel_winder

signature.asc (204 bytes) Download Attachment