I'm trying to solve problem where I'm doing a math computation on main thread and I want to move it into child process. The problem is that I can't come up with an simple solution how to do that.
Here's what I have already:
- I investigated child_process.exec
- Managed to pass and return simple data to and from the process (like Fibonacci seq)
Problem that I can not solve:
- My calculation uses array of objects (like:
[{x: 1, y: 2, z: 3}, ...]
) - child_process.exec can only pass command line arguments
- I can not figure out how can I pass complex data structures to child process?
Maybe there is a library that can abstract all this logic and I could do something like:
doHeaveComputation(function (result) {
//do something with result
});
Thank you for help