best ways to do clean up

Juan Pablo L jpablolorenzetti at
Wed Dec 29 19:07:22 CET 2010

actually i already fixed my problem trying to follow libev way, my problem
is that i m replacing all gilb loop things in an already built and working
so i m trying to cause as little modifications as possible in the code, is
not my intention to emulate glib with libev but i have to rebuilt some
custom watchers originally in glib
with libev and at the same time do not want to do big changes in the code
which may lead to changes in the architecture ...
i m just trying to get the best of libev
and that can only be achieved following libev way of doing things. so far so
good, i m just having little issues with libev but because there are things
that i still dont have a clear understanding  .... for now this is fixed !!!
thank you for your support!!!

On 29 December 2010 11:31, Marc Lehmann <schmorp at> wrote:

> On Tue, Dec 28, 2010 at 11:19:58PM -0400, Juan Pablo L <
> jpablolorenzetti at> wrote:
> > be very efficient and useful but since i have no experience with other
> event
> > library other than glib i can not stop my self from trying to do same
> with
> > libev.
> The design of glib's mainloop is very interesting, unfortunately it
> precludes
> any kind of optimisation, each loop run the loop has to query each watcher
> repeatedly.
> In a sense, glib doesn't actually offer support for event sources, each
> watcher has to implement them on their own. This makes it's watchers very
> generic, and is a remarkably different design to basically any other event
> loop.
> This is probably quite fine in an environment where you want to watch at
> most one fd and half a dozen timers (for which glib was designed).
> When you don't want to pay this overhead, then you need to tell the event
> loop in advance about the event sources you are interested in, which is
> why most event loop designs ask you to register interest in specific
> events, as opposed to registering some object with behaviour.
> > since i m customizing an ev_async, in glib you create a custom watcher
> and
> > you can override the prepare and check functions (also the finalize
> > function) so when the loop loops it calls your prepare and check
> functions
> > for only this custom watcher without affecting the prepare/check/finalize
> > functions that may be in the same loop, is this possible with libev that
> is,
> > to customize the prepare and check functions only for particular watcher
> > without affecting the other watchers in the loop ??? i ask this because i
> > find this to be very useful to me.
> I am sure I don't quite understand your problem, because it really is
> the same way in libev. There is no such thing as per-loop prepare/check
> functions - the only way to get these events is to register watchers for
> them, and then only those watchers which have been started will receive
> these events.
> So basically, you register an ev_prepare and ev_check watcher, and then
> your watcher will be called before and after polling for events.
> Note, however, that prepare/check are almost always the wrong way to do
> things, they are only useful if you want to include events that libev
> cannot handle itself (for example, because the software you use doesn't
> give you enough information to create watchers yourself).
> The reason they are usually wrong is that they are called each time the
> event
> loop polls for events. This is the only way to do things with glib, which
> is
> why it is the right thing there, but from a performance standpoint, you
> have
> to avoid it when possible.
> Maybe you should describe your actual goal, i.e. what are you tring
> to achieve, instead of trying to achieve your goal with something
> (check/prepare) that might not be the right tool in the first place?
> --
>                The choice of a       Deliantra, the free code+content MORPG
>      -----==-     _GNU_    
>      ----==-- _       generation
>      ---==---(_)__  __ ____  __      Marc Lehmann
>      --==---/ / _ \/ // /\ \/ /      schmorp at
>      -=====/_/_//_/\_,_/ /_/\_\
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the libev mailing list