in reply to Re: Is it possible to perform concurrent action like loop?
in thread Is it possible to perform concurrent action like loop?

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.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."
  • Comment on Re^2: Is it possible to perform concurrent action like loop?

Replies are listed 'Best First'.
Re^3: Is it possible to perform concurrent action like loop?
by zentara (Cardinal) on Mar 20, 2009 at 15:53 UTC
    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.


    I'm not really a human, but I play one on earth My Petition to the Great Cosmic Conciousness