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

Re: [Libevent-users] bufferevent_base_set and threads

On Tue, Aug 6, 2019 at 2:41 AM Scott Dorr <j.scott.dorr@xxxxxxxxx> wrote:
> ThreadA receives a new connection and creates a new bufferevent to handle the IO. Sometime later, it needs to hand responsibility for that connection off to another thread.
> Can ThreadA use something like bufferevent_base_set to ‘move’ that bufferevent to the other thread (ThreadB) so that callbacks associated with it are triggered in ThreadB’s context?

bufferevent_base_set() will work but with a few caveats:
- will *work* only for plain bufferevent sock (created with
- will *fail* if you already enables some events (EV_READ/...), hence
you need to buffevent_disable/bufferevent_base_set/bufferevent_enable

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