Closed CoolCat467 closed 3 years ago
Because of "too long without yielding" error. On low-end servers/clients computer will hang in grouping process of large pictures before saving/serializing them. Grouping is required for color palette optimization and reducing file/string size without any compression methods like deflate. On small pictures like OS icons computer.pullSignal
will not be called.
Unlike OpenOS, MineOS does not replace the native computer.pullSignal
function with a custom one in event.lua
- therefore, you can safely call it any time, this will not trigger cascade execution of event handlers registered in the Event
library. I deliberately avoid "function replace method" as I consider it "anti-pattern" that is hard to manage and potentially leading to the consequences that you have described (accidental execution of handlers when it's not needed). MineOS itself uses event.pull
, not computer.pullSignal
- so, we can assume that computer.pullSignal
is just a low-level method, that was left untouched for such rare cases as "force sleeping for N secs for preventing TLWY errors" or something else
Btw I haven't encountered the need to turn off signal processing while doing anything... In which case do you have such a need? Or are you just wondering why this stuff needed?
I was just curious, because I couldn't tell why it was required just from the code. That makes perfect sense though! And I agree about the function overwriting thing. Thank you for explaining it.
I was looking at the Image API, and I noticed that in the local function "group" and in the module function "toString", every 603 pixels computer.pullSignal(0) is called. I was wondering why, because doing that would cause signals during that period to bypass being handled by the event API's handlers. I'm sure there's a reason for it, but I don't quite understand. Thank you for your time.