J
J
JackShcherbakov2019-03-26 17:32:56
Node.js
JackShcherbakov, 2019-03-26 17:32:56

SetImmediate - splitting a heavy computational task. Do I understand correctly?

Hello!
Let's say there is a very large computational task and I want to break it into parts and execute each part in one iteration of the libUV event loop, and not all at once. Let's say I broke it into 3 parts. Suppose like this:

function part1(){...}
function part2(){...}
function part3(){...}

The code contains reading files, requests to the server from users, etc.
Is it correct to split the execution like this:
setImmidate(){

part1() //на след. итерации цикла

   setImmidate(){

      part2() //на след. итерации цикла

      setImmidate(){

         part3() //на след. итерации цикла

      }
   }
}

Thanks in advance to everyone who helps!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question