[squeak-dev] exploration of Cryptography's Local Promises (was: Re: Debugging of other processes with wait)

Robert Withers robert.withers at pm.me
Fri Jul 24 20:51:58 UTC 2020

Hi Jakob,

I always want to assume best intentions, so I apologize for being somewhat snarky in my last post. I am not offended nor am I mad at you. Please don't be with me.

On 7/23/20 2:00 PM, Robert Withers wrote:

> I have asked you several times to comment on the Promise implementation in PromisesLocal, but you have not responded.
>> Installer ss project: 'Cryptography'; install: 'PromisesLocal'.

In consideration of my promises, I realize you may not understand what I am proposing with the PromisesLocal package. It is a robust amount of functional code. PromisesLocal attempts to be a working implementation of the behaviors from ERights' ELib Concurrency [1], which predates Mark Miller's joining Google Research for the new JavaScript standard with his Promises/A+. I believe now that the differences between the Promise in Kernel-Proccesses and PromisesLocal is that PromisesLocal solves the concurrency issues, with its concurrency model. Read about this here:

[1] ELib's concurrency - http://www.erights.org/elib/concurrency/index.html

So allow me to demonstrate the outcomes of using PromisesLocal.

First image, taking a look at the Workspace, in the lower left above the Transcript, we have a good send, an exception send, and then another good send, demonstrating that the event loop does not get blocked. The first and last explorers resolve to 420. The middle explorer becomes a BrokenERef, due to the ZeroDivide. As well there is a debugger open for this exception, opened on a stack copy of the signaler context. The event loop continues to run but we have another process opened in the debugger.

For this debugger logic, please see

StandardToolSet class>>debugEventualException: anException
"For convenience. Construct a helper process to debug an exception that occurred in the active process later on so that the active process can (try to) resume. Uses a temporary variable to access and copy the signaler context now before it gets GC'ed."

| helperProcess |
helperProcess := (EventualProcess
forContext: anException signalerContext copyStack
priority: Processor activeProcess priority
onVat: Processor activeProcess vat)
shouldResumeFromDebugger: true;

Project current addDeferredUIMessage: [
debugWithTitle: anException description
full: false].

I am calling this in EventualMessageSend>>#value if an exception occurs during the send.

Second image is of the situation after proceeding from the Debugger and then running the first line a second time, getting another NearERef of 42. The event-loop is active.

The third image demonstrates the PriorityVat running #nextProcessMsg (the event loop!) as well as another process for the ZeroDivide exception and its copied stack.

Finally, allow me to add a halt in the Vat's machinery to halt when an exception is handled in EventualMessageSend>>#value, this will halt on the ZeroDivide, after resolving the promise to broken, but before the stack copy of the signalerContext. This is before the helperProcess is made, so we see in the Processes there is the event loop open in the debugger (look for the process with a priority of 30). As this broke before the last item in the normalQ of the vat, the last explorer still shows a Promise. The event loop is blocked. When the Debugger is resumed or abandoned, the event loop DIES a quiet death, so we must clear it an restart the #local Vat, to regain operability, thus the new first line in the Workspace. I believe that adding a strategic call to #ifCurtailed: would be helpful here, to restart the Vat. i am unsure where to put this call.

I hope the workspace examples give you more familiarity of use and these images show what is actually happening with PromisesLocal.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200724/f720856b/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Promise-event-loop-test-halt.jpg
Type: image/jpeg
Size: 307818 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200724/f720856b/attachment-0004.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Promise-event-loop-test-processes.jpg
Type: image/jpeg
Size: 47352 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200724/f720856b/attachment-0005.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Promise-event-loop-test-post-proceed.jpg
Type: image/jpeg
Size: 226442 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200724/f720856b/attachment-0006.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Promise-event-loop-test.jpg
Type: image/jpeg
Size: 234846 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200724/f720856b/attachment-0007.jpg>

More information about the Squeak-dev mailing list