[MSEide-MSEgui-talk] TTimer.options := [to_single] ?

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

[MSEide-MSEgui-talk] TTimer.options := [to_single] ?

fredvs
Hello Martin.

I did extensive test of a project on processors i386 (32 and 64 bit)
Linux/FreeBSD/Windows.

OK, on all OS, perfect.

But on arm rpi 32 bit, there was problems, for example zooming was not
working any more.

After hard investigations, I did find something that fixes all.

The problem (seems to) come from a TTimer that (strangely) makes trouble.
This timer is called after a TForm.resize() and even if the form is not
resized, it is called on rpi...

This fixes all:

TTimer.options := [to_single];

Sadly I cannot isolate the problem with a simple demo.

On my project ( Strumpract <https://github.com/fredvs/strumpract>  ), you
can test it that way:

In waveform.pas, change the option of ttimer1 to:

TTimer.options := []; ----> on my rpi ---> problems, cannot zoom anymore +
lot of ressource used.

I do not want to annoy you with this because the problem seems to be fixed
now.

But what is TTimer.options = [to_single], what is the difference if not use
that option ?

After the waveform.pas ttimer problem, for security, in all the units, I did
add the option [to_single] for all the ttimer.

Thanks.

Fre;D



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] TTimer.options := [to_single] ?

mse
Administrator
On Friday 22 June 2018 13:16:39 fredvs wrote:
> Hello Martin.
>
>
> But what is TTimer.options = [to_single], what is the difference if not use
> that option ?
>
With to_single the timer will be fired once after ttimer.enabled will be set
to true. Without to_single it will be triggered repetitive after setting
ttimer.enabled to true. I saw that you fiddle with ttimer.enabled in
ttimer.ontimer. I never understand why you do this and IIRC several times
corrected it. If you need a repetitive interval timer don't set to_single and
don't touch ttimer.enabled in ttimer.ontimer.

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] TTimer.options := [to_single] ?

mse
Administrator
In reply to this post by fredvs
On Friday 22 June 2018 13:16:39 fredvs wrote:
>
> TTimer.options := []; ----> on my rpi ---> problems, cannot zoom anymore +
> lot of ressource used.
>
If the time used in ontimer is bigger than the interval time there will be
100% CPU power used and the delayed ontimer events will be called when the
CPU load allows it.
If you want to skip missed intervals because of excessive time used in ontimer
please activate ttimer.options to_leak.

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] TTimer.options := [to_single] ?

fredvs
In reply to this post by mse
>  I never understand why you do

Huh, in my mind, a timer works like this:

Interval is the time between 2 ontimer-method.

I start the timer with mytimer.enabled := true;

If I want only one ontimer-method then I use mytimer.enabled := false in the
ontimer-method.

Also, in code I use:

mytimer.enabled := false; // this to reset the interval of timer if he is
already working,
mytimer.enabled := true; // this to (re)start the timer.

For example when resizing a form, a timer is started but if the one resize
the form again before the end-interval of the timer, I want to restart the
timer at beginning of interval.

But you have a other way to deal with timer, so I need to study your
advices.

Write you later.

Fre;D






--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] TTimer.options := [to_single] ?

mse
Administrator
On Friday 22 June 2018 21:34:01 fredvs wrote:

> >  I never understand why you do
>
> Huh, in my mind, a timer works like this:
>
> Interval is the time between 2 ontimer-method.
>
> I start the timer with mytimer.enabled := true;
>
> If I want only one ontimer-method then I use mytimer.enabled := false in
> the ontimer-method.
>
to_single is intended for the purpose.

> Also, in code I use:
>
> mytimer.enabled := false; // this to reset the interval of timer if he is
> already working,
> mytimer.enabled := true; // this to (re)start the timer.
>
> For example when resizing a form, a timer is started but if the one resize
> the form again before the end-interval of the timer, I want to restart the
> timer at beginning of interval.
>
ttimer.restart() is intended for the purpose.

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] TTimer.options := [to_single] ?

fredvs
Hello Martin.

OK, capito the use of to_single.  Thanks for the light.

> Without to_single it will be triggered repetitive after setting
> ttimer.enabled to true

> don't touch ttimer.enabled in ttimer.ontimer.

OK.

But how do you do for something like this:

procedure ttimer.ontimer();
begin
if all_is_ok then dothis_and_continuetimer()
else dothat_and_stoptimer();
end;

?

Fre;D



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] TTimer.options := [to_single] ?

mse
Administrator
On Saturday 23 June 2018 12:14:06 fredvs wrote:

> Hello Martin.
>
> OK, capito the use of to_single.  Thanks for the light.
>
> > Without to_single it will be triggered repetitive after setting
> > ttimer.enabled to true
> >
> > don't touch ttimer.enabled in ttimer.ontimer.
>
> OK.
>
> But how do you do for something like this:
>
> procedure ttimer.ontimer();
> begin
> if all_is_ok then dothis_and_continuetimer()
> else dothat_and_stoptimer();
> end;
>
> ?
>
dothis_and_continuetimer() does not need to change ttimer.enabled, setting
ttimer.enabled to false in dothat_and_stoptimer() is OK.

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] TTimer.options := [to_single] ?

fredvs
> setting ttimer.enabled to false in dothat_and_stoptimer() is OK.

Hum,...

Why not directly in ttimer.ontimer() ?

 procedure ttimer.ontimer();
 begin
 if all_is_ok then dothis_and_continuetimer()
 else ttimer.enabled := false;
 end;
 
This question because of:
> don't touch ttimer.enabled in ttimer.ontimer.

?



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] TTimer.options := [to_single] ?

mse
Administrator
On Saturday 23 June 2018 21:53:38 fredvs wrote:

> > setting ttimer.enabled to false in dothat_and_stoptimer() is OK.
>
> Hum,...
>
> Why not directly in ttimer.ontimer() ?
>
>  procedure ttimer.ontimer();
>  begin
>  if all_is_ok then dothis_and_continuetimer()
>  else ttimer.enabled := false;
>  end;
>
> This question because of:
> > don't touch ttimer.enabled in ttimer.ontimer.
>
Sure, no problem. I symply used your terms. But I must ask, what do you mean
with "dothis_and_continuetimer()"? I want to avoid another misapprehension.
With "don't touch ttimer.enabled in ttimer.ontimer" I meant do not
"
<timer.enabled> := false
[...]
<timer.enabled := true;
"
in a repetitive ontimer handler I saw in your code several times.

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] TTimer.options := [to_single] ?

fredvs
>I meant do not
><timer.enabled> := false
> <timer.enabled := true;

OK, it is what I did understand . ;-)

Thanks for your notes.

Fre;D



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk