Oz and Mozart Hackers Mailing List

Re: Merge of the "new ByNeed" branch


From: duchier@ps.uni-sb.de
Date: Thu Dec 04 2003 - 11:29:50 CET


raph@info.ucl.ac.be (Raphael Collet) writes:

> The first idea was to create one thread instead of two. In the semantic
> version, '!!' and ByNeed create one thread each. Second, if {P} returns
> a free variable Z, R must be bound to a read-only view of Z.

Ah yes, of course! Thanks!

> Maybe it is simpler to synchronize on Y before binding R. The following
> avoids the creation of a second read-only, without breaking semantics:
>
> ByNeedFuture = proc {$ P X}
> R={Boot_Value.newReadOnly}
> in
> thread
> {WaitNeeded R}
> try Y={P} in
> % necessary if R has no demanding suspension
> {Boot_Value.makeNeeded Y}
> {WaitQuiet Y} {Boot_Value.bindReadOnly R Y}
> catch E then
> {Boot_Value.bindReadOnly R {FailedValue E}}
> end
> end
> X=R
> end

I like this better, but I think it has a slight bug when P might
actually wait until Y becomes needed. Instead, I would make Y needed
right away:

ByNeedFuture = proc {$ P X}
                  R={Boot_Value.newReadOnly}
               in
                  thread
                     {WaitNeeded R}
                     try Y in
                        {Boot_Value.makeNeeded Y}
                        {P Y}
                        {WaitQuiet Y}
                        {Boot_Value.bindReadOnly R Y}
                     catch E then
                        {Boot_Value.bindReadOnly R {FailedValue E}}
                     end
                  end
                  X=R
               end

> - {ByNeed P X} currently creates a thread with {WaitNeeded X} {P X}.
> Maybe we can create a cheap suspension on X that, whenever X becomes
> needed, creates the actual thread with {P X} on it.

Interesting idea.

> - {ByNeedFuture P X} could use the same technique as ByNeed above.
> Simply make X a read-only with a cheap suspension that creates a
> thread whenever X becomes needed.

If you think about it, my suggestion is a trivial specialization of
your idea: make a read-only-like variable with one slot (aka your
suspension) for P. It's a lot easier than your more general scheme
and we could have it fairly soon. It could be replaced by your more
general scheme when it becomes available.

> Kevin and I don't think those have to be done for the upcoming release.
> Maybe for 1.3.1...

Of course, but if we could have them (or at least an optimized
ByNeedFuture) that would be so much nicer :-)

Cheers,

-- 
Denys Duchier - Équipe Calligramme - LORIA, Nancy, France
-
Please send submissions to hackers@mozart-oz.org
and administriva mail to hackers-request@mozart-oz.org.
The Mozart Oz web site is at http://www.mozart-oz.org/.



This archive was generated by hypermail 2b29.