Re: [Libevent-users] EV_WRITE - Wait for a socket or FD to become writeable.

2012-09-03 Thread Nir Soffer
On Sep 3, 2012, at 8:13 PM, Parvez Shaikh wrote: Purpose of doing this is to make only one thread access socket descriptor. I have to use multiple threads(thread pool that does some mundane processing of messages) for utilizing multiple cores as much as possible(each thread access no sha

Re: [Libevent-users] EV_WRITE - Wait for a socket or FD to become writeable.

2012-09-03 Thread Parvez Shaikh
Hi Nir, Purpose of doing this is to make only one thread access socket descriptor. I have to use multiple threads(thread pool that does some mundane processing of messages) for utilizing multiple cores as much as possible(each thread access no shared resource except queuing message for send); als

Re: [Libevent-users] EV_WRITE - Wait for a socket or FD to become writeable.

2012-09-03 Thread Nir Soffer
On Mon, Sep 3, 2012 at 1:05 PM, Parvez Shaikh wrote: > Thanks Oleg and Nir. > > I am also pursuing another approach. Here I have defined a custom event > (associated with FD but not having either EV_READ or EV_WRITE) and there is > no time out either. > > A thread queues data to "outgoing message

Re: [Libevent-users] EV_WRITE - Wait for a socket or FD to become writeable.

2012-09-03 Thread Parvez Shaikh
Thanks Oleg and Nir. I am also pursuing another approach. Here I have defined a custom event (associated with FD but not having either EV_READ or EV_WRITE) and there is no time out either. A thread queues data to "outgoing message list" and activates an event. In response to this, event reactor t

Re: [Libevent-users] EV_WRITE - Wait for a socket or FD to become writeable.

2012-09-02 Thread Nir Soffer
On Sun, Sep 2, 2012 at 6:54 AM, Parvez Shaikh wrote: > Thanks Oleg, > > Second approach is what I am doing. > > Why disabled EV_WRITE in write callback? > > I'd wish to have this callback called again whenever send buffer has > space, so disabling EV_WRITE will prevent this. You want to enable E

Re: [Libevent-users] EV_WRITE - Wait for a socket or FD to become writeable.

2012-09-02 Thread Oleg
If you need such approach then do not disable it. But remember that if you have no data in queue your callback anyway will be called immediately after wait() function.This consumes your CPU. But if you're sure that queue size is always > TCP send buffer size then you're approach is right. 02.0

Re: [Libevent-users] EV_WRITE - Wait for a socket or FD to become writeable.

2012-09-01 Thread Parvez Shaikh
Thanks Oleg, Second approach is what I am doing. Why disabled EV_WRITE in write callback? I'd wish to have this callback called again whenever send buffer has space, so disabling EV_WRITE will prevent this. On Fri, Aug 31, 2012 at 3:54 PM, Oleg wrote: > EV_WRITE calls whenever you can write t

Re: [Libevent-users] EV_WRITE - Wait for a socket or FD to become writeable.

2012-08-31 Thread Oleg
EV_WRITE calls whenever you can write to send buffer until it's not full. So if you have never called send(), but EV_WRITE is enabled you will receive this event each new loop (your CPU will be ~100% used). If you have called send() and it didn't return EAGAIN you will also receive this event ne

[Libevent-users] EV_WRITE - Wait for a socket or FD to become writeable.

2012-08-30 Thread Parvez Shaikh
Hi all, I have a question about EV_WRITE event as to when does it's callback function invoked? Is it that when someone first executes write on an fd associated with EV_WRITE event? Or when libevent detects that application can now write to fd without getting errors? For EV_READ it is easy to un