It effectively allows you to run things simultaneously.
Um, no. Not even close.
Event loops run everything serially, in the same single thread. They will not benefit from multi-cores or multi-processors.
And if those things are cpu-bound, they will (collectively) run more slowly than if you just run them one after the other in the normal way.
Events loops are only useful for code that spends most of it's doing nothing but wait. Eg. communications servers and guis.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
Well, his original code example was a simple count. He could have multiple timers running in an event-loop system, counting multiple things, and unless he pushed system load limits, it would run fine.Saying the loop runs things sequentially is true, but misleading... because in a single processor computer, all processes get run sequentially anyways.....the execution pointer can only be in one place at a time. So event-looping is just extending what the kernel does, on a per-process basis. But yes, if your loops are resource hogs, it may be neccessary to fork or thread. It's like using IO::Select....do you avoid "select" because it's usage usually loops over it's select array? No, you use it, but keep in mind it's limitations.
| [reply] |