[sheepdog] [PATCH 1/2] lib: prioritize events for epoll() and enhance event loop

Hitoshi Mitake h.mitake at gmail.com
Fri Dec 21 08:52:46 CET 2012


At Fri, 21 Dec 2012 15:36:24 +0800,
Liu Yuan wrote:
> 
> > # sheepkeeper is a heavy user of REFRESH, mainly for processing
> > # leaving of sheeps. If you are wondering about the use case of it,
> > # I can send this patch as a part of sheepkeeper patchset. Which one
> > # do you prefer?
> > 
> 
> No, you'd better push prepare patches into the code first as much as
> possible for better review.

OK, I'll send v2 as an independent patchset later.

> 
> >>
> >> nr = epoll_wait(efd, polled_events, nr_events, TICK * 1000);
> >> if (nr < 0)
> >>     ...
> >> else if (nr) {
> >>     if (need_sort)
> >> sort:
> >>         sort events...
> >>     for (i = 0; i < nr; i++) {
> >>          ret = ei->handler(ei->fd, e, ei->data);
> >>          switch (ret) {
> >>          case EVENT_LOOP_OKAY:
> >>               break;
> >>          case EVENT_LOOP_RETRIEVE:
> >>               retrieve new events;
> >>               goto sort;
> >>          case EVENT_RET_BREAK:
> >>               goto out;
> >>     }
> >> out:
> >>     ...
> > 
> > Is this pseudo code different from the scheme of my patch?
> > 
> 
> Yes, pseudo code. your previous code structure looks unnecessary complex
> to me.
> 

I understand. The complexity would be reduced by eliminating
the unnecessary array.


Thanks,
Hitoshi



More information about the sheepdog mailing list