[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[Libevent-users] mixing libevent and boost::asio



Is there a good way of interacting between those two libraries?

I'm trying to mix two single threaded libraries - one built for each platform. It's simple to poll each library but this this seems to mean either introducing a sleep in the loop of spinning a full speed.

a naive approach...
....
 while (true)
  {
   Â// does not block but might handle several events
   Âint s1 = event_base_loop(_event_base, EVLOOP_NONBLOCK);Â
  ÂÂ
   Â// handles at most 1 event
   size_t n = ios.poll(); Â
   Âif (n>0)
     Âcontinue;
   Âboost::this_thread::sleep(boost::posix_time::milliseconds(1));Â
  }

Is there a way of waiting for both sets of file descriptors so I don't have to rely on the timer or a busy loop to poll both events?

I know I can have one thread running the libevent queue and another the boost::asio eventloop but that gives problems when the callbacks in each subsystem calls the other.

I'm familiar with boost but not libevent so please bear with me if this question is trivial in libevent context...

/svante