Run Arbitrary Code While Waiting For Callback in Node?

前端 未结 2 980
遥遥无期
遥遥无期 2020-12-20 09:24

I\'m a beginner in Node right now. I understand that callbacks prevent Node from blocking while waiting for I/O or some other process, but what is Node doing while waiting f

2条回答
  •  北海茫月
    2020-12-20 10:12

    It's doing nothing while waiting. But it might wait for multiple IO actions to finish, and then will invoke the callback for the one that finishes first. So if you are waiting for multiple connections, node will do something everytime a connection opens. It will even do that if some code triggered by the first connection has registered a callback to wait for some file IO in the meantime.

提交回复
热议问题