* Copyright © 2006 Pierre Habouzit
*/
+#include <pthread.h>
#include <sys/epoll.h>
#include <sys/socket.h>
#ifndef EPOLLRDHUP
int event = events[count].events;
int evt = 0;
+ gettimeofday(&w->mru, NULL);
switch (w->state) {
case EL_LLP_INIT:
w->llp(w);
return 0;
}
+void *el_loop(void *data)
+{
+ time_t sec = time(NULL);
+
+ for (;;) {
+ struct timeval now;
+
+ el_dispatch(100);
+ pthread_testcancel();
+
+ gettimeofday(&now, NULL);
+ if (sec >= now.tv_sec)
+ continue;
+ sec = now.tv_sec;
+ now.tv_sec -= 10;
+ for (int i = jobs.len - 1; i >= 0; --i) {
+ job_t *w = jobs.arr[i];
+ if (timercmp(&now, &w->mru, >))
+ IGNORE(w->m->on_event(w, EL_EVT_WAKEUP));
+ }
+ }
+}
+
void el_initialize(void)
{
gnutls_global_init();