Michael,
Thanks a lot for this pointer. I had a look at the VW RecursionLock class, and implemented something similar. I will probably need to improve it by giving blocks unwind protection, which I think is done in Tims exceptions package. Anyway, you will be pleased to know that this technique is exactly what is needed to prevent nested event triggering from blocking the PostOffice semaphore.
Thanks again!
Peter
I have found this to be a problem with OO and Semaphores in general - there is so much cross-calling of messages it is difficult to predict when a locked message will call itself. It would be good to have a "smart semaphore" that forced outside callers to wait, but let self invoke multiple invocations
VW has a RecursionLock which is basicly a "smart Semaphore" that knows which Process holds the lock, thereby alowing recursive calls into the protected sections -- invaluable for thread-safe (I.E. Smalltalk Process-safe) code.
I've also found other similar smart mutex's to be usefull. I had a TimeZone class which called-out to the OS (Unix) for doing timezone calculations. Unfortunately, the Unix libraries have the timezone global to the OS's process. I had a lock that blocked all entrants who wanted to do a calculation in a different zone than the zone held by the lock.
Generally, I find that simple mutexes around small block's of code arise from cleaner designs. Recursion locks are bigger armour-plating for putting around large pieces of functionality, usually in concert with general exception handling.
-- Mike klein
mklein@alumni.caltech.edu