Semaphore>>critical:

Stephen Pair spair at acm.org
Fri Dec 6 10:51:27 UTC 2002


This methods reads:

-----
critical: mutuallyExcludedBlock 
	"Evaluate mutuallyExcludedBlock only if the receiver is not
currently in 
	the process of running the critical: message. If the receiver
is, evaluate 
	mutuallyExcludedBlock after the other critical: message is
finished."

	| blockValue |
	self wait.
	[blockValue _ mutuallyExcludedBlock value]
		ensure: [self signal].
	^blockValue
-----

I've been using the following version for quite some time without any
trouble:

-----
critical: mutuallyExcludedBlock 
	"Evaluate mutuallyExcludedBlock only if the receiver is not
currently in 
	the process of running the critical: message. If the receiver
is, evaluate 
	mutuallyExcludedBlock after the other critical: message is
finished."

	self wait.
	^mutuallyExcludedBlock ensure: [self signal]
-----

Is there any reason why my version is not correct?  Again it seems to
work, and it gets much more to the point.

- Stephen 




More information about the Squeak-dev mailing list