More Delay/Semaphore "fun"

Igor Stasenko siguctua at gmail.com
Sat Oct 6 00:04:21 UTC 2007


The problem is obviously in wait primitive.
Instead of simply return nothing, it should make difference between
successful wait and wait, which is abandoned due to process
termination.

I don't know if that possible to implement without VM modifications,
but wait primitive should work like:

self wait: afterwaitBlock

where afterwaitBlock accepts single boolean value - true means wait
successful and false means that it abandoned(process terminated).

or same, in slightly different form:

self waitOk: [ wait ok ] failed: [ wait failed ].

Then, you should never raise signal for abandoned wait, while can do
it if you successful on waiting:

self waitOk: [  [...] ensure: [ self signal ] failed: [ ".. do nothing"  ]

^^ but again, this code sometimes can fail (you can manage to
terminate process, when you entered in #waitOk: block, but before you
send #ensure: ) , so again, you have chances to not raise signal if
your process terminates shortly.

Another variant, since we don't really need to have block for handle
abandoned waits, then wait primitive can be a composition of two wait
and ensure, which is:

self waitOk: [ ".... working code .." ] ensureAfter: [ "This block
will be evaluated only if we entered working block and regardless
after it terminated or finished in regular way"  ]

And if wait abandoned, none of blocks should be evaluated.

-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list