On Fri, Feb 24, 2017 at 10:43 PM, Tôn Loan <[email protected]> wrote: > Hi Jan and Steffen, > > Thank all of you for giving the solution as well as experience about > multi-threading > > @Jan: Getting these things right can take some trial and error; one thing > I'd advise is to look at what mature projects do, because they have > often (though not always) done all the mistakes and learned from them. > > Can you suggest me some mature projects as you said?. I searched many times > but I have not enough experience to choose the mature project to follow
Hi, What about mature projects with libevent and multiple threads you can take a look at libevhtp in particular (but this is for TCP): https://github.com/ellzey/libevhtp/blob/develop/evthr.c It uses socketpair() to distribute jobs between threads (AFAIR). Also there already was similar question, you can read it too: http://archives.seul.org/libevent/users/Mar-2016/msg00007.html And I'm voting for not using threads until you really need them too (and indeed sometimes syncing primitives can make it slower then single-threaded program). Plus what you are describing here (every thread use it's own port) can be implemented with spawning multiple processes (but maybe it won't be optimal choice indeed). Hope this helps. Cheers, Azat. *********************************************************************** To unsubscribe, send an e-mail to [email protected] with unsubscribe libevent-users in the body.
