On Wed, Jan 16, 2008 at 04:12:02PM -0200, Leandro Lucarella <[EMAIL PROTECTED]> wrote: > Marc Lehmann, el 16 de enero a las 05:43 me escribiste: > I'm trying to go back to this design, but I'm starting to need the loop to > be virtual again because, I can't put ev_xxx_destroy () call in the > destructor in the ev::loop (to follow the proposed names above).
Ah, because you shouldn't, you can just put the relevant destructor into loop_dynamic and loop_default, as a mere loop will not destruct the loop, it will be merely a container for the loop pointer. > if ~loop () is empty and each destructor has it own ev_xxx_destroy () > call, then when using a loop pointer, you can't destroy the loop > because of the lack of virtualness: Thats fine, a virtual destructor isn't really neecssary for a thin interface. think about it: you *need* to use the right type to construct, and you should use the same type when deleting, i.e. the problem will only come up when you: loop_dynamic *l = new loop_dynamic; delete (loop *)l; That is pretty dumb to begin with. Besides, I would expect most loops not to be dynamically allocated at all, but just be static global objects, or members of some other object. I do not see the reason for a dynamically allocating a loop itself. So... I don't really see the need for a virtual destructor (again, just because this is suppused to be a very thin interface). > Maybe there's not much use for something that needs to treat a loop and a > default loop the same (like a container) since they are completely > different beasts, but the problem is still there. You still can treat them the same everywehre except when constructing or destructing the object, in which case it makes sense to to use the correct type: neither loop has any derived types, and this is the only case where the problem comes up. -- The choice of a Deliantra, the free code+content MORPG -----==- _GNU_ http://www.deliantra.net ----==-- _ generation ---==---(_)__ __ ____ __ Marc Lehmann --==---/ / _ \/ // /\ \/ / [EMAIL PROTECTED] -=====/_/_//_/\_,_/ /_/\_\ _______________________________________________ libev mailing list libev@lists.schmorp.de http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev