My robot

Lesson 5: Non-blocking v.s. blocking

Blocking refers to operations that block further execution until that operation finishes while non-blocking refers to code that does not block execution.
Blocking methods execute synchronously while non-blocking methods execute asynchronously.

Non-blocking operations allow a single process to serve multiple requests at the same time.
For example, the first sentence in the example English code
The robot goes forward. The robot says hallo.
will generate a driving block with no time/distance restrictions. It will not block the next command from executing.

Therefore, it is a non-blocking block.

On the other hand, the process of blocking operations blocks and waits for operations to complete.
For example, the first sentence in the example English code
The robot goes forward 10 cm. The robot says hallo.
will generate a driving block with distance requirement for 10 cm.

Thus, the block will explicitly drive 10cm before the next command "say hallo".
In another word, this block will be blocking the next command before it is fully executed.

👈 Previous: Lesson 4 🏠 Homepage 📚 Lesson plan