Skip to content

Instantly share code, notes, and snippets.

@azat
Created November 14, 2016 21:56
Show Gist options
  • Save azat/d76de36a8980b888e111a267666b1794 to your computer and use it in GitHub Desktop.
Save azat/d76de36a8980b888e111a267666b1794 to your computer and use it in GitHub Desktop.
/**
libevent
user-triggered event example
*/
#include <event2/event.h>
void cb(int fd, short events, void *arg)
{
puts("cb");
}
int main()
{
struct event_base *base = event_base_new();
struct event *event = event_new(base, -1, EV_READ, cb, NULL);
event_active(event, 0, 0);
puts("start event loop");
event_base_loop(base, 0);
puts("exit event loop");
return 0;
}
@azat
Copy link
Author

azat commented Nov 14, 2016

$ ./a.out
start event loop
cb
exit event loop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment