<br><br><div class="gmail_quote">On Mon, Oct 22, 2012 at 2:17 AM, Clément Bera <span dir="ltr"><<a href="mailto:clement.bera@inria.fr" target="_blank">clement.bera@inria.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br><br>I don't understand something on BlockClosure>>ensure:. Why does it use 'self valueNoContextSwitch' and not 'self value' ? In which case is there an issue ? </blockquote><div><br></div>
<div>Prior to my closure implementation BlockContext>>value[:value:*] was not a context switch point. So to preserve the threading semantics of ensure: we implemented ensure: in terms of BlockClosure>>valueNoContextSwitch, which is not a context-switch point, as opposed to BlockClosure>>value[:value:*]. The context switch points in the VM are non-primitive sends (or failing primitives, i.e. full method activation), backward branches, the Process primitives suspend, resume, signal and wait (and CrtiticalSection/Mutex enter and exit) and block evaluation.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><br></div><div>Thank you for any answers<br>
<br>BlockClosure>>ensure: is implemented this way :<br><br>ensure: aBlock<br>        "Evaluate a termination block after evaluating the receiver, regardless of<br>         whether the receiver's evaluation completes. N.B. This method is *not*<br>
         implemented as a primitive. Primitive 198 always fails. The VM uses prim<br>         198 in a context's method as the mark for an ensure:/ifCurtailed: activation."<br><br>        | complete returnValue |<br>        <primitive: 198><br>
        returnValue := <b>self valueNoContextSwitch</b>.<br>        complete ifNil:[<br>                complete := true.<br>                aBlock value.<br>        ].<br>        ^ returnValue<br><br></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>