Page 1 of 1

Posted: 23 Dec 2015, 04:45
by ahonoe
Doing lots of "code optimization" these days and I'm wondering what the most CPU friendly way of waiting one bloc is in a script.

If I understand correctly, setting a flag based on polling an input in the main process block of a script, and then executing code using a condition will allow me to span blocs. Compared to the event-driven fast callback procedure, continuously polling and looping in the body seems processing intensive.

Is there a way that I can trigger a script's execution using the callback but have it wait one bloc to update an output? Can I simply move the flag-&-conditional-evaluation into a procedure called from the fast callback?

Posted: 25 Dec 2015, 20:35
by 23fx23
what i do is on callback procedure when according input changes i set a counting variable value to 0. then on process only if that value is positive it counts to N blocs and reverts to -1 when max is reached, until a new event is trigged and so on

Posted: 29 Dec 2015, 18:53
by ahonoe
Thanks 23fx23. Doesn't this mean that the processing block is continuously running to check your counting var?

Posted: 30 Dec 2015, 08:52
by 23fx23
yes could be reduce to bool but im not sure something lower cpu could be found, since a process procedure will necessarely need something to be trigged. Unless i missed something time relative blocs manipulation cannot rely only on callbacks procedures