[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] bufferevent_pair_new vs socketpair
- To: libevent-users@xxxxxxxx
- Subject: [Libevent-users] bufferevent_pair_new vs socketpair
- From: Sergey Zhemzhitsky <szh.subs@xxxxxxxxx>
- Date: Tue, 11 Jun 2013 21:35:28 +0400
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Tue, 11 Jun 2013 13:36:03 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:x-priority:message-id:to:subject:mime-version :content-type:content-transfer-encoding; bh=SPB8ArPEQNkHQUsYa4LqLc3hEjQDlYPBUJ4bd7VrDPA=; b=M1wf4oRiGWRalDQRZcIC0b1x2HnrTY9li5zMceA3Y/F7NRK/FHSJ6TQGAvuCli4EVs a8ck1QJRpnLKoxLalLJ7hdRWyg4yDWRxojYySygytKMUP7ASFFfujCt4oa7gCneojCeB u3umug/d8J7Olr1XSqs+1hJVrU4i+Asbr+ERmuenmGB+Bs4yMbT6airuwawq7eUZq4vd T/9yVjS6+R6ERpWDIV6Lat7cqWrV3LjQBCaaLIAbgD7XTRhwLETsD1OMeP+hqOnyo+MR SH6ubPBMQb5r25gWbCqXBYoq0WULEgy8e0gOQDBS7q9oIGXTWbNVNmsmtuedDrU53Oxm U/FA==
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
Title: bufferevent_pair_new vs socketpair
Hello libevent gurus!
I'm trying to implement multithreaded libevent application and have a few questions.
Consider there are two threads: thread_1 and thread_2, each running using its own separate event base, so libevent is not configured to be thread safe.
Now I need these two threads to communicate to each other, but I don't like to introduce any locks, so I'm wondering what mechanism is better to use: bufferevent_pair_new or socketpair?
Do I have to use BEV_OPT_THREADSAFE with bufferevent_pair_new if the first thread will always write the data into the one end of bufferevent_pair and the second thread will always read the data from another end of the bufferevent_pair?
With socketpair(AF_UNIX), I don't need to use locks, but it requires syscalls.
Looking through the sources of libevhtp (https://github.com/ellzey/libevhtp/blob/master/evthr/evthr.c#L283) I found that for multithreading this library uses socketpairs and I don't understand why so if there is bufferevent_pair.
So, what is the preferable and faster way to communicate between threads?
Regards,
Sergey
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.