NodeJs how to create a non-blocking computation

前端 未结 5 1698
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-10 01:53

I am trying to get my head around creating a non-blocking piece of heavy computation in nodejs. Take this example (stripped out of other stuff):

http.createS         


        
5条回答
  •  我在风中等你
    2020-12-10 02:37

    If you computation can be split into chunks, you could schedule executor to poll for data every N seconds then after M seconds run again. Or spawn dedicated child for that task alone, so that the main thread wouldn't block.

提交回复
热议问题