Learning the mechanics of the Rune Code Async block

I understand the “Run Code Async” block in the Logic section is Backendless’ version of paralell flows/actions. However, I’m not sure I understand how it works exactly and haven’t been able to find much documentation. A few questions I have:

  • Will the blocks inside of the async wait until the blocks above the Async have run before starting?
  • Will the blocks after the async wait until the blocks inside the async have completed?
  • Is it that all of the blocks inside the Async block run simultaneous with each other?
  • And/or is it that everything inside the Async runs simultaneously with the entire action flow?

Hello @David_King

  1. yes
  2. no
  3. no
  4. didn’t get your question

Async block works like another thread, everything inside one async block will be ignored by a main thread(it will not wait), but still have priority inside it.

Here is an example:

image

And call order:
myFunction1 - start
myFunction1 - end
myFunction2 and myFunction4 - start
myFunction2 - end
myFunction3 - start

Regards, Dima

Hello @David_King

It’s easier to explain with an example

Output: 1,2,3,4

Output: 1,2,4,3

In the first case, we have to wait for the result of the “Logout” request to call the “print 4”, in the second case, we do not wait for the response to the request to call the “print 4”

Regards,
Viktor

Follow-up question, is there a way to create a flow like the following:
Functions 1-5 all run simultaneously via “run code async”
Function 6 runs only after 1-5 have all completed

Hi @David_King ,
for such a flow you can use custom code, below I have shown an example of how this can be implemented.
If you have any more questions, feel free to contact us, we are always happy to help.

async function promiseAll(promises) {
  return Promise.all(promises)
}

Regards,
Sergey