I have nodejs app that needs a few infinite loops which call async functions. I was considering implementing the following:
async function execute1() {
...do some async work...
}
async function execute2() {
...do some async work...
}
setInterval(execute1, 500)
setInterval(execute2, 500)
My concern is that if the async functions will take a long time to complete, the open references will pile up and this can result in a memory crash down the line.
- is setInterval the right tool for this job? is there a more suitable tool?
- What is the most elegant method to make sure the execute() function will not start if the previous run hasn't return?