Hi Michael, Using a thread for each connection is exactly what libevent (async IO) is trying to simplify and prevent. The right way would be to use a single event base with a single thread for all these connections.
If you want to scale it to multiple cores: you can divide the connections between a couple of event bases + threads (each thread running an event base). 10x, Tomer. -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Michael Sent: Tuesday, March 15, 2016 8:58 AM To: [email protected] Subject: [Libevent-users] std::threads Hi All, This is Michael from CMU. I am currently using libevent in our database system (https://github.com/cmu-db/peloton/wiki) to let the cluster nodes to communicate with each other. I want to ask how can I use multiple std::threads on the same event_base. For example, a server has a event_base. When a new connection coming, the server creates a std::thread with a socket_event, and puts the socket_event into the event_base. If there are ten connections, there are ten std::threads sharing the same event_base. (Each threads has it own socket_event to recv and send data). Can I implement that? Is there an example? I appreciate your help! Best, Michael *********************************************************************** To unsubscribe, send an e-mail to [email protected] with unsubscribe libevent-users in the body.
