Changeset 654c8eb13631b85718782ab77fca1e99d6fc5126

Show
Ignore:
Timestamp:
04/29/10 15:43:03 (8 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1272555783 +0000
git-parent:

[daa524aff5ff1bae944a21d81a4e2dc12a0fbc70]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1272555783 +0000
Message:

behaves very nicely on my Mac. refs #273

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/eventer/eventer_kqueue_impl.c

    r1aca1b7 r654c8eb  
    5353#include "eventer/eventer_impl_private.h" 
    5454 
     55static const struct timeval __dyna_increment = { 0, 1000 }; /* 1 ms */ 
    5556static pthread_t master_thread; 
    5657static int kqueue_fd = -1; 
     
    316317static int eventer_kqueue_impl_loop() { 
    317318  int is_master_thread = 0; 
     319  struct timeval __dyna_sleep = { 0, 0 }; 
    318320  pthread_t self; 
    319321  KQUEUE_DECL; 
     
    333335    int fd_cnt = 0; 
    334336 
    335     __sleeptime = eventer_max_sleeptime; 
     337    if(compare_timeval(eventer_max_sleeptime, __dyna_sleep) < 0) 
     338      __dyna_sleep = eventer_max_sleeptime; 
     339 
     340    __sleeptime = __dyna_sleep; 
    336341 
    337342    eventer_dispatch_timed(&__now, &__sleeptime); 
     343 
     344    if(compare_timeval(__sleeptime, __dyna_sleep) > 0) 
     345      __sleeptime = __dyna_sleep; 
    338346 
    339347    /* Handle recurrent events */ 
     
    367375      noitLT(eventer_err, &__now, "kevent: %s\n", strerror(errno)); 
    368376    } 
     377    else if(fd_cnt == 0) { 
     378      /* timeout */ 
     379      add_timeval(__dyna_sleep, __dyna_increment, &__dyna_sleep); 
     380    } 
    369381    else { 
    370382      int idx; 
     383      __dyna_sleep.tv_sec = __dyna_sleep.tv_usec = 0; /* reset */ 
    371384      /* loop once to clear */ 
    372385      for(idx = 0; idx < fd_cnt; idx++) {