[e-lang] E and FUSE-j integration

Kevin Reid kpreid at mac.com
Wed Sep 26 16:33:56 EDT 2007


On Sep 26, 2007, at 16:20, David Hopwood wrote:

> Toby Murray wrote:
>> (I suspect the solution here would be a general one that could be
>> applied to other situations in which one needs to implement a
>> synchronous interface using remote references.)
>
> It's possible to do that using a binary semaphore or equivalent.
> Something like (*untested code*):
...
>    def semaphore = <unsafe:java.util.concurrent.Semaphore>.new(-1,  
> false)
>    def succeeded :boolean
>    def vOutside :any
>    def probOutside: any

(Syntactic note: Forward declarations may not have guards.)

>
>    when (v) -> {
>       succeeded := true
>       vOutside := v

(Syntactic note: forward declarations are bound as "bind vOutside :=  
v".)

>       semaphore.release();
>    } catch prob {
>       succeeded := false
>       probOutside := prob
>       semaphore.release();
>    }
>    semaphore.acquire();
>    if (!succeeded) throw probOutside

(Syntactic note: if requires braces.)


>    return vOutside
...

No, you can't do this (ignoring the many syntactic problems): when  
you do semaphore.acquire(), you have blocked inside a turn, so the  
when-body cannot execute, nor can this vat receive the notification  
that the promise which "v" is a remote-promise-proxy for has resolved.

Also, vOutside is pointless -- v is not rebound by the when block.

-- 
Kevin Reid                            <http://homepage.mac.com/kpreid/>




More information about the e-lang mailing list