Epoll for D2

Adil Baig adil.baig at aidezigns.com
Sat Sep 8 06:17:16 PDT 2012


On Sat, Sep 8, 2012 at 2:49 PM, bearophile <bearophileHUGS at lycos.com> wrote:

> Adil:
>
>  https://github.com/adilbaig/**Epoll-D2<https://github.com/adilbaig/Epoll-D2>
>>
>
>  ev.events = EPOLL_EVENTS.IN | EPOLL_EVENTS.HUP |    EPOLL_EVENTS.ERR;
>>
>
> In D enums are kind of (but not really) strongly typed,


"are kind of (but not really) strongly typed" - I didnt know that. How?


> so writing them all in UPPERCASE is often a bad practice. So something
> more similar to this seems nicer:
>
> ev.events = EpollEvents.in | EpollEvents.hupxxxxx | EpollEvents.error;
>
>
I'm trying to keep the learning curve to a minimum so some one using this
library doesn't need to "double lookup" what it means. The original epoll
#defines are EPOLL* (ex: EPOLLIN, EPOLLHUP, EPOLLONESHOT ..), hence the
naming scheme EPOLL_EVENTS.* . But i do take your point. I'm thinking
Events.* ; Events.IN, Events.HUP etc. Succinct and fairly obvious. Looks
good?


>
>  epoll.add(int file_descriptor, ev);
>>
>
> Is this correct D syntax?
>
> I slipped into pseudo-code there. epoll works with file descriptors
(including its own), not just sockets, hence i didn't write
"epoll.add(listener_socket.handle(), ev)"


> Bye,
> bearophile
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-announce/attachments/20120908/e946dac6/attachment.html>


More information about the Digitalmars-d-announce mailing list