0

I'm curious to know if anyone else has tried this... I'm about to give it a go, but was hoping someone else may have some experience to share before I sit here at 11:00 pm (having to go to work in the morning) to try this.

If I load up a few threads, and from each thread create an event base and create listen events on the same fd, how would libevent respond to that? Would only one of the event bases end up winning and triggering an event, or would each one end up triggering the event?

  • I guess your goal is to make use of other CPU cores by employing threads... in which case, what you could do is to have one thread receiving all the incoming events which simply puts them on to a buffer and then have a pool of threads which each then take the events off the buffer and process them. So if you had a 4-core CPU, you'd have one thread receiving events and a pool of three worker threads. I've done this and it works. – SlappyTheFish Sep 05 '16 at 07:37

1 Answers1

0

Well, I went ahead and coded it up real quick. Unfortunately, as I suspected, every single event base fires off an event. So with four threads, each with their own unique event base and set of events on the same fd, it triggered the function four times.