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

[Libevent-users] Two event base in multi threaded application vs one event base?



Hi experts,

While setting socket FD in event loop, should FD be set non-blocking (using fcntl)?

Further I am confused about how to use libevent and would really appreciate some technical inputs on below.

I am in a process of designing multi-threaded application and would like  a main thread - a thread that calls event_base_dispatch to do both read and write on FD (potentially around 100 FDs).

However I am in a dilemma, should I have two threads running event_base_dispatch - one that polls for EV_READ and another for EV_WRITE for same FD set or one thread that polls for EV_READ as well as EV_WRITE?

First approach would not let READ operations getting delayed due to much time being spent in  WRITE operations(due to large data pending) while second approach appears more cleaner there is only one thread that is polling for events.

Any suggestions?

Thanks