Try to search your question here, if you can't find : Ask Any Question Now ?

How to make event created by libevent work only when the event is true in cpp?

HomeCategory: stackoverflowHow to make event created by libevent work only when the event is true in cpp?
Avatarwillson asked 2 weeks ago

I was able to use libevent to trigger a function every n seconds but is there a way to utilize or do something when events are not active? How can it be achieved?

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

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

  int a = 3;

  tv.tv_sec = 1;
  tv.tv_usec = 0;

  event_init();

  event_set(&ev, 0, EV_PERSIST, say_hello, &a);
  evtimer_add(&ev, &tv);
  event_dispatch();
  printf("stuff") # what's the most sensible way to do this if event 
  return 0;       # not active?
}

1 Answers
Best Answer
AvatarAmit answered 2 weeks ago
Your Answer

16 + 18 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com