Timers auto self unregister when the times (3rd parameter) is met. Returning anything else, or nothing, does not unregister the callback. The callback also has the option to return false ( nil is not the same, specifically false) to unregister itself. OnTimeout() is called every 1s, and 10 times (see the event api for details). Handle_key_down() is called every time there is a key_down signal. The event handler function is a callback that is called every time the condition under its registration is satisfied. ![]() System yielding methods include: term.read, os.sleep, and event.pull. If you need your application to sleep for 10s before resuming its work, and you call os.sleep(10), you block execution of the the foreground application (because are in the same thread). When developing a background application this is a critical workflow to understand. For all intents and purposes, all coroutines in that thread are essentially suspended. If you create multiple coroutines and resume them in a continuous loop, once any single coroutine makes a system yield call – your loop would be blocked on that one coroutine. OpenOS creates a single init thread and runs all processes inside that one thread. In contrast, the system call computer.pullSignal yields the current thread (event.pull and os.sleep also call computer.pullSignal). During a machine blocking call nothing in the system is running. Thus we generally are not referring to machine blocking calls when we discuss whether an operation is blocking or not. ![]() These blocking calls are outside the control of the operating system, are truly blocking, and outside our control. Machine blocking calls are a subset of component api, such as a filesystem file read, which cause the entire OpenComputer machine state to wait. There are two distinct types of blocking calls: machine blocking and system yielding. When building a background process you need to know what is a blocking call, and what is blocked when you call it.
0 Comments
Leave a Reply. |