What is a blocking function?

前端 未结 3 1594
囚心锁ツ
囚心锁ツ 2021-02-20 03:59

What is a blocking function or a blocking call?

This is a term I see again and again when referring to Node.js or realtime processing languages.

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-20 04:24

    var block = function _block() {
      while(true) {
        readInputs();
        compute();
        drawToScreen();
      }
    }
    

    A blocking function basically computes forever. That's what it means by blocking.

    Other blocking functions would wait for IO to occur

    a non-blocking IO system means a function starts an IO action, then goes idle then handles the result of the IO action when it happens.

    It's basically the difference between a thread idling and sleeping.

提交回复
热议问题