ticker reset crashes

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
Locked
HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

ticker reset crashes

Post by HPW »

Testing the ticker code from the doc work so far, but trying to reset it as desribed crashes newLISP:

Code: Select all

> (define (ticker)(println (date)) (timer 'ticker 10.0))
(lambda () (println (date)) (timer 'ticker 10))
> (ticker)
Tue Sep 05 22:52:04 2006
10
> Tue Sep 05 22:52:14 2006

> Tue Sep 05 22:52:24 2006

> (define (ticker)(println (date)) (timer 'ticker 0.0))
(lambda () (println (date)) (timer 'ticker 0))
> (ticker)
Tue Sep 05 22:52:31 2006
0
> Tue Sep 05 22:52:31 2006
Tue Sep 05 22:52:31 2006
Tue Sep 05 22:52:31 2006
Tue Sep 05 22:52:31 2006
Tue Sep 05 22:52:31 2006
Tue Sep 05 22:52:31 2006
Tue Sep 05 22:52:31 2006
Tue Sep 05 22:52:31 2006
Tue Sep 05 22:52:31 2006
I tested with newLISP-tk and the DLL version.
Hans-Peter

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

You cannot change a function while it is running. That will always crash.

To stop the ticker you could set some global variable for the ticker time and then change that variable to a different value, or some similar scheme.

Lutz

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

I tried the follwoing but I still gets the crash:

Code: Select all

newLISP v.8.9.8 on Win32 MinGW.

> (setq MyTime 10.0)
10
> (define (ticker)(println (date)) (timer 'ticker MyTime))
(lambda () (println (date)) (timer 'ticker MyTime))
> (ticker)
Wed Sep 06 07:37:04 2006
10
> Wed Sep 06 07:37:14 2006

> Wed Sep 06 07:37:24 2006

> (setq MyTime 0.0)
0
> Wed Sep 06 07:37:34 2006
Wed Sep 06 07:37:34 2006
Wed Sep 06 07:37:34 2006
Wed Sep 06 07:37:34 2006
Wed Sep 06 07:37:34 2006
Wed Sep 06 07:37:34 2006
....
....
What is wrong?
Seems to get into a endless loop and gets some overflow?
Hans-Peter

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

>Seems to get into a endless loop and gets some overflow?

Lutz, any idea here?
Hans-Peter

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Yes, after reviewing the code I realize setting the time to 0.0 only works on UNIX. On Win32 the timer is implemented in a different way using windows thraeds and watching the time in the thread, it is taking the 0.0 as a very short time and goes into a loop.

But I am sure there is a way to implement that feature in Win32 too. Look out for it in the next development version.

Meanwhile you could use this workaround:

Code: Select all

(define (ticker)
    (println (date)) 
    (if (> MyTime 0.0) (timer 'ticker MyTime)))
Lutz

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

But I am sure there is a way to implement that feature in Win32 too. Look out for it in the next development version.
Great! And thanks for the workaround.
Hans-Peter

Locked