Hi, I am developing a server app with libevent now.
My app has a main thread with event loop handling all network
comm/timer events,
and a worker thread to do some 'labor' stuff like DB operation.
I use a pair of buffered event to inter-comm between main thread and
worker thread.
like this in main thread:
bufferevent_pair_new( get_event_base() , BEV_OPT_THREADSAFE , pair);
bufferevent_setcb(pair[0], trampoline_readable,trampoline_writable
, trampoline_event , (void*) this);
bufferevent_enable(pair[0], EV_WRITE | EV_READ );
same does pair[1];
Now I write some message in worker thread like this:
bufferevent_write(bev, data, size);
I expect that read_cb could be awaken immediately in main thread, but
it doesn't.
The read_cb deferred infinitely until other event occurs (i.e. timer
or siginal),
the I can successfully fetch msg from read_cb.
Am I missing something?
I create the buffered event pair in main thread while write to one of
them in worker thread, is this OK?
Thanks in advance.
***********************************************************************
To unsubscribe, send an e-mail to [email protected] with
unsubscribe libevent-users in the body.