help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] UUID and Monitor Squeak classes equivalent in gst?


From: Nicolas Petton
Subject: Re: [Help-smalltalk] UUID and Monitor Squeak classes equivalent in gst?
Date: Wed, 17 Jun 2009 13:22:08 +0200

Thanks Paolo, I'll have a look at those classes.

One other question, is there something like the MessageTally class in
Squeak?.

This class is especially useful when used together with Seaside (in
WAProfiler).

Cheers!

Nico


Le mercredi 17 juin 2009 à 08:32 +0200, Paolo Bonzini a écrit :
> > Coming from Squeak, I'm used to its class libraryand I didn't find any
> > equivalent of the UUID and Monitor classes. 
> 
> UUID is implemented as part of the platform layer of Magritte, though 
> with the time-based UUIDv1 algorithm if I remember correctly.
> 
> I think if you're using only Monitor>>#critical: the equivalent is 
> RecursionLock.  For more complicated stuff, Semaphore has additional 
> methods #notify (like #signal, but never increment the count above 0) 
> and #notifyAll (to wake up all processes).  For example, this example of 
> Squeak monitors
> 
> BoundedCounter>>dec
>       monitor critical: [
>               monitor waitUntil: [value > self lowerBound].
>               value = self upperBound ifTrue: [monitor signalAll].
>               value _ value - 1].
> 
> BoundedCounter>>inc
>       monitor critical: [
>               monitor waitUntil: [value < self upperBound].
>               value = self lowerBound ifTrue: [monitor signalAll].
>               value _ value + 1].
> 
> could be written like this:
> 
> BoundedCounter>>initialize
>       mutex := RecursionLock new.
>       condition := Semaphore new.
> 
> BoundedCounter>>dec
>       | oldValue |
>       [mutex critical: [
>           value > self lowerBound ifTrue: [
>               value = self upperBound ifTrue: [condition notifyAll].
>               value _ value - 1. ^self]].
>       condition wait] repeat
> 
> BoundedCounter>>inc
>       [mutex critical: [
>           value < self upperBound ifTrue: [
>               value = self lowerBound ifTrue: [condition notifyAll].
>               value _ value + 1. ^self]].
>       condition wait] repeat
> 
> (I'm pretty sure that the Monitor class in Squeak has race conditions 
> that may leave the monitor in an unstable state if the involved 
> processes are terminated; see the complications in 
> Semaphore>>#critical:.  That's why I never got to implementing it in GNU 
> Smalltalk).
> 
> Paolo

Attachment: signature.asc
Description: Ceci est une partie de message numériquement signée


reply via email to

[Prev in Thread] Current Thread [Next in Thread]