[e-lang] multiway when-catch
Rob Withers
reefedjib at yahoo.com
Mon Oct 29 17:50:20 EDT 2007
----- Original Message -----
From: "Kevin Reid" <kpreid at mac.com>
> On Oct 29, 2007, at 15:36, Rob Withers wrote:
>>> From: "Kevin Reid" <kpreid at mac.com>
>>> I think your promiseSet corresponds to the components produced by
>>> promiseAllFulfilled, which multiway-when uses, as you will see in
>>> the expansion. I recommend that you simply compile/translate
>>> promiseAllFulfilled.emaker to your platform, as it is entirely non-
>>> primitive and well-designed.
>>
>> I was unable to find promiseAllFulfilled.emaker, but I am still
>> looking.
>
> esrc/org/erights/e/elang/interp/
Cool. I also liked promiseAllResolved.emaker, which is what I have actually
duplicated. I also send whenResolved:, but I don't check for broken refs.
>>> Particularly, there should not be any weak references involved, so
>>> GC is irrelevant.
>>
>> I have strong references. I think I may have fixed the problem I
>> was having by passing the promiseSet as an argument to the
>> #whenResolved: msgs I send to each promise. I am now resolving
>> the promiseSet and getting into the block.
>
> This sounds like inadequate facets. What authority does a promiseSet
> grant to its holders? If it includes the promises it holds, then this
> is wrong, as the promises should not learn of each other by being
> used together in a when.
>
> Could you explain what a promiseSet is? It does not sound like any
> concept that exists in E, and so I am suspicious of its necessity. Is
> it primitive?
A promiseSet is a list of promises. I have refactored it to look very much
like promiseAllResolved.emaker. Since we can't have standalone functions, I
needed to add #whenResolved: as a method somewhere. It holds a collection
of promises and offers this protocol:
% eventualRef
"Add an eventualRef to the list"
refs add: eventualRef.
initialize
refs := OrderedCollection new.
whenResolved: reactor
| countDown |
countDown := refs size.
refs do: [:each |
each whenResolved: [:aRef |
countDown := countDown - 1.
countDown <= 0
ifTrue: [reactor valueWithArguments: refs asArray]]].
>
>> One other question I had, I once saw code that conditioned a
>> promise to resolve within a certain timeout, otherwise it broke.
>> Do you happen to know code that could do this?
>
> The final example (building on previous ones) in <http://
> www.erights.org/elang/concurrency/race.html> .
Awesome! Thanks,
Rob
More information about the e-lang
mailing list