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

RE: [Libevent-users] std::threads

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). 


-----Original Message-----
From: owner-libevent-users@xxxxxxxxxxxxx [mailto:owner-libevent-users@xxxxxxxxxxxxx] On Behalf Of Michael
Sent: Tuesday, March 15, 2016 8:58 AM
To: libevent-users@xxxxxxxx
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!

To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.