Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Modern computers CPU’s are astoundingly fast. They can perform super large amounts of operations in a fraction of a second.

What is slow is input output operations - I/O operations in jargon. By this we mean:

  • Reading/Writing files to disk

  • Waiting for network operations to complete etc.

Calls to the operating system which perform input/output operations can either be:

  • Blocking - which means that the thread of execution pauses until the I/O operation completes.

  • Non-blocking - which means that the call returns instantly - but we pass in a pointer to a function which will be called back when the call returns. We also call this asynchronous I/O.

Using blocking I/O calls can work fine if you are on a single thread which does not have an event loop on it. If you are using an event loop though then one should either be using non blocking asynchronous I/O or fire off threads which do blocking I/OFunction calls can be blocking. This means that the function will not return control until the operation is completed.

Another model is non-blocking or asynchronous. This means that the caller:

  • Needs to supply a callback function when the call is made.

  • The function will return instantly.

  • But later a callback will come

Underneath this concept page we discuss a whole load of implications of this.