[E-Lang] Confusion
Marc Stiegler
marcs@skyhunter.com
Thu, 16 Aug 2001 07:46:38 -0700
Steve,
To reliably acquire a result from a remote server after a particular message
has been sent to that server, place the behavior you desire inside a
when-catch, as in:
def newXpromise := farCounter <- incr()
when (newXpromise) -> done(newX) {
println("new X is: " + newX)
} catch prob {println("problem: " + prob)}
The trace you got in Elmer was the result of looking at X at moments which
appear "random" in the course of the updates of x and fulfillments of
promises.
Does that help? Or have I not understood the question?
Note that if you had 2 different vats sending incr() messages at different
times, the value of the X in the
when-catch might still vary because of randomness in when the arrival of
those messages from the third vat interleaved with the incrs being sent by
the vat using the when-catch. If you want a single incr service dedicated to
yourself, the service should be a CounterMaker, and you would create a new
one for yourself. If you have a thousand agents in the field, all
incrementing the counter, and you want to know exactly how high the tally
was at a guaranteed moment in time (when there might be thousands of counts
trapped behind bottlenecked Internet routers, but so it goes), you would
have the server return both the number and the time when the number was
retrieved.
--marcs
----- Original Message -----
From: "steve jenson" <stevej@sieve.net>
To: <e-lang@mail.eros-os.org>
Cc: <markm@caplet.com>; <marcs@skyhunter.com>
Sent: Thursday, August 16, 2001 3:02 AM
Subject: [E-Lang] Confusion
> In working on some E code to serve as an exmple to others, I've run into
> a gap in my knowledge:
>
> First, I have an E script called server.e:
>
> ---
> #!/usr/bin/env e
>
> def x := 1
>
> def counter {
> to incr() :any { println("counter was incr()'d"); x += 1}
> to getX() :any { x }
> }
>
> introducer onTheAir()
> def sr := sturdyRef(counter)
> def uri := introducer sturdyToURI(sr)
> println(uri)
>
> interp blockAtTop()
> ---
>
> And I have an elmer transcript called client.updoc:
>
> ---
> ? introducer onTheAir()
> # value: ["3DES_SDH_M2", "3DES_SDH_M"]
>
> ? def uri :=
"cap://66.92.8.63:3575/08TsZ_LYmtuAVuLZoDFX8j3Re7O6/QfWE9V6br29mY9eS27aFI9fy
Gam"
> # value:
"cap://66.92.8.63:3575/08TsZ_LYmtuAVuLZoDFX8j3Re7O6/QfWE9V6br29mY9eS27aFI9fy
Gam"
>
> ? def sr := introducer sturdyFromURI(uri)
> # value: <SturdyRef>
>
> ? def farCounter := sr liveRef()
> # value: <Eventual ref>
>
> ? def newX := farCounter <- incr()
> # value: <Eventual ref>
>
> ? def newY := farCounter
> # value: <Eventual ref>
>
> ? newY <- incr()
> # value: <Eventual ref>
>
> ? newY <- getX()
> # value: <Eventual ref>
>
> ? farCounter <- incr()
> # value: <Eventual ref>
>
> ? newY <- incr()
> # value: <Eventual ref>
>
> ? def newX := farCounter <- incr()
> # value: <Eventual ref>
>
> ? newX
> # value: 6
>
> ? newY <- incr()
> # value: <Eventual ref>
>
> ? newX
> # value: 6
>
> ? newY
> # value: <Eventual ref>
>
> ?
> ? def newX := farCounter <- incr()
> # value: <Eventual ref>
>
> ? newX
> # value: 8
> ---
>
> I think this transcript shows my confusion about how to acquire the value
> held in the variable x by server.e's counter object.
>
> help! Where is my thinking not lining up properly?
>
>
> regards,
> steve
>
> PS, the cap is still online (at least until I wake up tomorrow morning and
> turn it off) if anybody out there wants to play with it. Not that it's
> super-exciting.
>
> --
> steve jenson <stevej@sieve.net> http://sieve.net/
> PGP fingerprint: 79D0 4836 11E4 A43A 0179 FC97 3AE2 008E 1E57 6138
> _______________________________________________
> e-lang mailing list
> e-lang@mail.eros-os.org
> http://www.eros-os.org/mailman/listinfo/e-lang
>