Non-Blocking Functions :: Waddon
From Grahamsoft Labs
The use of non-blocking functions is used to simulate a multitasking environment where the use of threads isn’t possible. Non-blocking functions return execution back to its caller even when it hasn’t completed its operation. Each time execution is returned the caller checks its status and recalls the function if it has not completed. The benefit of this design is that many functions can be poled very quickly one after another making it appear that tasks are happening simultaneously.
Code Example
void Main()
{
while ( ( Manage_Comms() != Command_Complete ) && ( Manage_Railway() != Command_Complete ) );
}
Both Manage_Comms() and Manage_Railway() functions will be called again and again until they both return Command_Complete. The program will then exit.
