Skip to content

Instantly share code, notes, and snippets.

@mythosil
Created August 9, 2011 10:45

Revisions

  1. mythosil created this gist Aug 9, 2011.
    24 changes: 24 additions & 0 deletions libevent_timer.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    #include <stdio.h>
    #include <sys/time.h>
    #include <event.h>

    void say_hello(int fd, short event, void *arg)
    {
    printf("Hello\n");
    }

    int main(int argc, const char* argv[])
    {
    struct event ev;
    struct timeval tv;

    tv.tv_sec = 3;
    tv.tv_usec = 0;

    event_init();
    evtimer_set(&ev, say_hello, NULL);
    evtimer_add(&ev, &tv);
    event_dispatch();

    return 0;
    }