[Ur] Triggering JavaScript context switches

Adam Chlipala adamc at csail.mit.edu
Fri Aug 26 12:44:33 EDT 2016


I think Saulo indeed managed to reverse engineer the correct answer, 
and, to save future questioners from the same detective work, I've added 
a description in Section 8.6 of the manual.  (Its compiled PDF version 
will go up on the web with the next Ur/Web release.)

Thanks, Benjamin, for pointing out this documentation hole.

On 08/21/2016 07:13 PM, Saulo Araujo wrote:
> Hi Benjamin,
>
> I believe that, besides sleep, only the functions rpc and recv also 
> trigger context switches. If you look into the source code of the 
> Ur/Web JavaScript runtime (urweb.js), you will see that there is a 
> boolean variable called maySuspend, which says when context switches 
> are allowed and the only functions that check the value of maySuspend 
> are sl (sleep), rc (rpc) and rc (recv).
>
> Sincerely,
> Saulo Araujo
>
> On Sat, Aug 20, 2016 at 5:25 PM, Benjamin Barenblat <bbaren at mit.edu 
> <mailto:bbaren at mit.edu>> wrote:
>
>     The threads demo* explains that ‘Ur/Web [client code] uses cooperative
>     multi-threading, not the more common preemptive multi-threading. Only
>     one thread runs at a time, and only particular function calls can
>     trigger context switches. In this example, sleep is the only such
>     function that appears.’ What other functions can trigger context
>     switches?
>
>     * http://impredicative.com/ur/demo/threads.desc.html
>     <http://impredicative.com/ur/demo/threads.desc.html>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.impredicative.com/pipermail/ur/attachments/20160826/23a60e8c/attachment.html>


More information about the Ur mailing list