Critical sections (was: RE: Lots of concurrency)

Stephen Pair spair at advantive.com
Fri Oct 26 16:49:00 UTC 2001


> I guess the meaning is clear, but it goes against normal 
> Smalltalk interpretation.  If you write a normal #critical 
> method, it will get sent to a different dynamic block every 
> time the above line of code is executed.  That's what a 
> Smalltalker will expect.  However, for this method to do what 
> is probably intended, it needs to search back and figure out 
> which *static* block it is associated with.  This can be made 
> to work if you have some Compiler support, but....  maybe a 
> syntax can be devised that fits the normal Smalltalk 
> execution of blocks.

Actually, in most Smalltalks, where full block closure semantics are
available, most Smalltalkers would expect the message to be sent to the
same block object each time the method is invoked.  A different block
context would get created, but there would only be one block closure.
If you change "Smalltalkers" to "Squeakers" in that statement, then I
would agree.

[...snip several examples of the bank account problem]

Your examples all use semaphores.  I thought that by "rephrase your
system in terms of message passing" meant do it without semaphores.  The
solution I had in mind was to reify the monetary denominations such that
you would have accounts that actually contain instances of Penny,
Quarter, Dollar, etc (not that banks actually have those funds in the
real world mind you...but that's another story).  Then the
synchronization could be handled by the underlying collection classes,
eliminating the need for it in your domain class.  However that solution
is a bit of overkill I think.

- Stephen





More information about the Squeak-dev mailing list