Sean,

On 23 Apr 2013, at 18:02, "Sean P. DeNigris" <[email protected]> wrote:

> Luc's class-side trick seems to work:
> Timer>>start
> 
>       | array |
>       array := WeakArray with: self.
>       process := self class createProcessFor: array. "tried passing self here,
> but it seemed to keep the process around"
> 
> Timer class>>createProcessFor: aWeakArray 
> 
>       [ [ aWeakArray first notNil ] whileTrue: [ 
>               | timer |
>               aWeakArray first interval asDelay wait.
>               "We have to check again if the timer was garbage collected 
> during the
> wait"
>               aWeakArray first ifNotNil: [ 
>                       aWeakArray first value: aWeakArray first value + 1.
>                       aWeakArray first announcer announce: (TimerValueChanged 
> to: aWeakArray
> first value) ] ] ] fork.

Are you sure it works ? 
How do you test ?

In my code, I tried to do exactly what you are doing, except for the 
announcement, but I don't think it works. 

I tried to formalize a test, but you probably have to use the #debug: on 
TestCase otherwise the test is run twice and fails on the first assert. It 
could well be that the test is bogus (does the finalization get a chance to run 
?).

It only works if I terminate the process via the Process Browser.

Any ideas ?

These are old school file outs in _UnpackagedPackage:

Attachment: TestTimer.st
Description: Binary data

Attachment: TestTimerTests.st
Description: Binary data


Sven





Reply via email to