[squeak-dev] Re: Some gotchas with #terminate and #critical:

Igor Stasenko siguctua at gmail.com
Thu Apr 30 16:11:12 UTC 2009


2009/4/30 Andreas Raab <andreas.raab at gmx.de>:
> Igor Stasenko wrote:
>>
>> What you think is following alternative implementation:
>>
>> critical: mutuallyExcludedBlock
>>        | blockValue caught |
>>        caught := false.
>>        [
>>                caught := true.
>>                [self wait.] ifCurtailed: [ caught:=false ].
>>                blockValue := mutuallyExcludedBlock value
>>        ] ensure: [caught ifTrue: [self signal]].
>>        ^blockValue
>>
>> avoids the need in having tricks in #terminate?
>
> It doesn't. For example:
>
>  sema := Semaphore forMutualExclusion.
>  p := [sema critical:[]] forkAt: Processor activePriority - 1.
>  sema critical:[( Delay forMilliseconds: 100) wait].
>  p terminate.
>  self assert: sema isSignaled.
>

Ok, any ideas how to ensure expected behavior without poking the context stack?
Because in new scheduler, a #wait implemented differently.

> Cheers,
>  - Andreas
>
>



-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list