setTimeout, setInterval, setWatch logic #265
Replies: 3 comments
-
Posted at 2014-05-03 by MrTimcakes As i understand it the Espruino doesn't multitask all watches, intervals and timeouts happen one after another. I encounter this when i tried to do a watch on a button when i made an infinite loop, woops. Somthing like this wouldn't work.
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-05-03 by DrAzzy You don't have to to anything like that. watches/timeouts/intervals do not interrupt other code that is running when the timeout/interval happens or the watched pin changes - they get queued up, and run after the other code is done. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-05-03 by Sacha Many thanks, that's perfect. Sacha |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2014-05-03 by Sacha
Hi Gordon,
Do i have to protect my function from calling twice in "parallel" ?
Let say i have a function that talks over an uart to a device. The communcation must happen in series and never parallel.
I call this function by setInterval/setTimeout and with setWatch. The protection is easy, i can set a variable inside the function at the beginning and clear it at the end ant checking for that.
I just want to know if it can happen.
Thanks
Sacha
Beta Was this translation helpful? Give feedback.
All reactions