This source file includes following definitions.
- timeout_cb
- main
   1 
   2 
   3 
   4 
   5 
   6 #ifdef HAVE_SYS_TYPES_H
   7 #include <sys/types.h>
   8 #endif
   9 #include <sys/stat.h>
  10 #ifndef WIN32
  11 #ifdef HAVE_SYS_QUEUE_H
  12 #include <sys/queue.h>
  13 #endif
  14 #ifdef HAVE_UNISTD_H
  15 #include <unistd.h>
  16 #endif
  17 #else
  18 #include <time.h>
  19 #endif
  20 #ifdef HAVE_SYS_TIME_H
  21 #include <sys/time.h>
  22 #endif
  23 #include <fcntl.h>
  24 #include <stdlib.h>
  25 #include <stdio.h>
  26 #include <string.h>
  27 #include <errno.h>
  28 
  29 #include <opal/event/event.h>
  30 
  31 int lasttime;
  32 
  33 void
  34 timeout_cb(int fd, short event, void *arg)
  35 {
  36         struct timeval tv;
  37         opal_event_t *timeout = arg;
  38         int newtime = time(NULL);
  39 
  40         printf("%s: called at %d: %d\n", __func__, newtime,
  41             newtime - lasttime);
  42         lasttime = newtime;
  43 
  44         timerclear(&tv);
  45         tv.tv_sec = 2;
  46         opal_event_add(timeout, &tv);
  47 }
  48 
  49 int
  50 main (int argc, char **argv)
  51 {
  52         opal_event_t timeout;
  53         struct timeval tv;
  54 
  55         
  56         opal_event_init();
  57 
  58         
  59         opal_evtimer_set(&timeout, timeout_cb, &timeout);
  60 
  61         timerclear(&tv);
  62         tv.tv_sec = 2;
  63         opal_event_add(&timeout, &tv);
  64 
  65         lasttime = time(NULL);
  66 
  67         opal_event_dispatch();
  68 
  69         return (0);
  70 }
  71