[JdeRobot] Doubt about timing in some threads

Victor Arribas v.arribas.urjc at gmail.com
Wed Mar 23 14:17:17 CET 2016


Hi Samuel!

It could be too late, by the way here you are [1] a portable generic
alternative I did several time ago.
As you can see at main.py [2], it is backward compatible ;)

Just add it to your PYTHON_PATH or to dist-packages and enjoy it.

[1]
https://github.com/jderobot-varribas/drone1/blob/master/periodic_thread.py
[2] https://github.com/jderobot-varribas/drone1/blob/master/main.py#L35-L43

2016-03-05 3:19 GMT+01:00 samartin <samuel.martinm en gmail.com>:

> Hi,
>
> In basic component, the timing of the thread is managed this way:
>
>         if (diff < 0 || diff > cycle)
>             diff = cycle;
>         else
>             diff = cycle - diff;
>
> Diff is the amount of time that it takes to execute the code, and cycle,
> how
> much time it should take the entirely cicle. What I do not understand is
> why
> if the code takes more time to execute than the cycle, it waits even
> longer.
> Wouldn't it be better to do something like this?:
>
>         if (diff < 0 || diff > cycle_gui)
>             diff = 0;
>         else
>             diff = cycle_gui - diff;
>
> Samuel
>
>
>
> --
> View this message in context:
> http://jderobot-developer-list.2315034.n4.nabble.com/Doubt-about-timing-in-some-threads-tp4642950.html
> Sent from the Jderobot Developer List mailing list archive at Nabble.com.
> _______________________________________________
> Jde-developers mailing list
> Jde-developers en gsyc.es
> http://gsyc.escet.urjc.es/cgi-bin/mailman/listinfo/jde-developers
>
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: http://gsyc.escet.urjc.es/pipermail/jde-developers/attachments/20160323/f6114bb8/attachment.htm 


More information about the Jde-developers mailing list