[squeak-dev] Some gotchas with #terminate and #critical:
siguctua at gmail.com
Thu Apr 30 06:40:17 UTC 2009
Currently i replacing all calls which affect the scheduling to
redirecting them to Processor, i.e. instead:
Processor doSomethingWith: self.
This is to ensure, that no code, in rest of classes , except
ProcessorScheduler deals with scheduling directly.
If i change the Semaphore>>wait method in that way, then it breaks the
trick which sitting in #terminate method :
"Figure out if we are terminating the process while waiting in
In this case, pop the suspendedContext so that we leave the ensure:
Semaphore>>critical: without signaling the semaphore."
(inSema == true and:[
suspendedContext method == (Semaphore compiledMethodAt:
suspendedContext := suspendedContext home.
What you think is following alternative implementation:
| blockValue caught |
caught := false.
caught := true.
[self wait.] ifCurtailed: [ caught:=false ].
blockValue := mutuallyExcludedBlock value
] ensure: [caught ifTrue: [self signal]].
avoids the need in having tricks in #terminate?
Igor Stasenko AKA sig.
More information about the Squeak-dev