[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] std::threads
On Sun, Mar 20, 2016 at 10:36:02AM -0400, Michael wrote:
> Thanks Azat, I got the problem. It is the lock and unlock. In my code I
> return before unlock (as follows). And an interesting thing is when I call
> bufferevent_lock(bev_) again it doesn't block and can return. It seems the
Because it uses recursive locking.
> blocking happens inside libevent. So I take a long time to find it out.
> Thanks!
>
> // Get the lengh a write buf
> int Connection::GetWriteBufferLen() {
> /*
> * Locking the bufferevent with this function will
> * lock its associated evbuffersas well
> */
> bufferevent_lock(bev_);
> struct evbuffer *output = bufferevent_get_output(bev_);
> return evbuffer_get_length(output);
> bufferevent_unlock(bev_);
> }
Ugh, you don't need this wrapper, since evbuffer_get_length() will use
bufferevent's lock automatically.
Cheers,
Azat.
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.