Exemple #1
0
 void add_to_fd_set(int fd, fd_set & rfds, unsigned & max, timeval & timeout) const
 {
     if (fd > INVALID_SOCKET) {
         FD_SET(fd, &rfds);
         max = (static_cast<unsigned>(fd) > max) ? fd : max;
     }
     if ((fd <= INVALID_SOCKET || this->object_and_time) && this->set_state) {
         struct timeval now;
         now = tvtime();
         timeval remain = how_long_to_wait(this->trigger_time, now);
         if (lessthantimeval(remain, timeout)) {
             timeout = remain;
         }
     }
 }
Exemple #2
0
 // Idle time in microsecond
 void update(uint64_t idle_usec)
 {
     if (!idle_usec) {
         return;
     }
     if (this->set_state) {
         timeval now = tvtime();
         timeval new_trigger = addusectimeval(idle_usec, now);
         if (lessthantimeval(new_trigger, this->trigger_time)) {
             this->trigger_time = new_trigger;
         }
     }
     else {
         this->set(idle_usec);
     }
 }
inline
void add_to_fd_set(wait_obj & w, SocketTransport * t, fd_set & rfds, unsigned & max, timeval & timeout)
{
    if (t && t->sck > 0){
        FD_SET(t->sck, &rfds);
        max = ((unsigned)t->sck > max)?t->sck:max;
    }
    if ((!t || t->sck <= 0 || w.object_and_time) && w.set_state) {
        struct timeval now;
        now = tvtime();
        timeval remain = how_long_to_wait(w.trigger_time, now);
        if (lessthantimeval(remain, timeout)){
            timeout = remain;
        }
    }
}