C++ APIs [Re: libevent-like callback in c++]

Tony Arcieri tony at clickcaster.com
Wed Jan 9 19:08:36 CET 2008


On Jan 9, 2008 8:28 AM, Leandro Lucarella <llucax at gmail.com> wrote:

> Is not that is a lot of work typing (that, as painful as it is, it's done
> only once ;), but the lack of a base "class" to have a container of
> watchers.
>
> I thought about a lot of solutions, but all has their drawbacks:
>
> * "Interfaces": a pure virtual base class with the basic operations
>  (start(), stop() mainly) and multiple inheritance for each watcher
>  (like struct io: ev_io, base { ... };).


This is what I ended up doing in the Ruby binding.  The Watcher base class
cannot be instantiated directly, instead only the subclasses can.  Each
subclass implements attach and detach methods to add and remove it from a
loop.

-- 
Tony Arcieri
ClickCaster, Inc.
tony at clickcaster.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.schmorp.de/pipermail/libev/attachments/20080109/f78ad2a0/attachment.htm 


More information about the libev mailing list