A question concerning application architecture

Marc Lehmann schmorp at schmorp.de
Tue May 8 16:54:26 CEST 2012


On Tue, May 08, 2012 at 04:16:46PM +0200, Marek <marek at octogan.net> wrote:
> Now, I was thinking about running a ev_loop per thread and triggering
> threads from other threads via ev_async_send() call.

That's the standard idea, yes.

> I would like to ask you if such a architecture is acceptable, and

It is certainly acceptable.

> ev_async_send() will
> not decrease performance dramatically (as it will still be a kind of
> spinlock/busy waiting occurs) ?

I don't quite understand that question, but you can judge yourself: in
the current release of libev, if ev_run is blocking in a syscall, then
ev_async_send will write a byte into a pipe (or use eventfd) to wake it
up, once at most, per iteration. if the other thread is busy it merely
sets a global variable that is checked before ev_run blocks.

> Plus, I would like to run some modules periodically, hence running
> ev_timer or ev_periodic in a thread's loop.

Sounds fine to me.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the libev mailing list