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

Re: [Libevent-users] Wait until the loop thread processes all the data?



It didn't work, some read buffer callbacks still didn't run. As far as
I understand, EVLOOP_ONCE only executes a round of callbacks, which is
not what I want (I want to flush all the writes/reads through the
socket pair, and execute all the callbacks it would trigger).

On Tue, Feb 20, 2018 at 8:43 PM, Aaron Sinclair <aaron@xxxxxxxxx> wrote:
> In the main thread after loopbreak, can you try calling event_base_loop() with the EVLOOP_ONCE flag?
>
> This will loop until it sees the remaining event, run it & then return.
>
>> On Feb 20, 2018, at 3:03 AM, Egor Tensin <egor@xxxxxxxx> wrote:
>>
>> Hello,
>>
>> Hopefully you can help me with a libevent issue that I'm stuck on. I
>> have two threads, one of which produces data, and the other runs
>> event_base_dispatch (receiving the data from the first thread,
>> processing it and sending it somewhere else). They communicate using a
>> pair of bufferevents (over a local socket pair). The issue is, the
>> first thread might be done with producing the data, program
>> termination being the next logical step. But I want to wait for the
>> second thread to 1) receive _all_ the data the first thread sent, 2)
>> process it and 3) send it to the final destination. I can't figure out
>> how to accomplish that, because if I call event_base_loopexit after
>> the first thread stops, it looks like the second thread exits right
>> after executing the current round of callbacks, discarding the latest
>> data that might have been sent by the first thread. Can somebody
>> please explain to me how to fix this? I can set a random timeout for
>> event_base_loopexit, but this is unreliable, isn't it?
>>
>> Regards,
>> Egor Tensin.
>> ***********************************************************************
>> To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
>> unsubscribe libevent-users    in the body.
>
> ***********************************************************************
> To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
> unsubscribe libevent-users    in the body.
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.