Can I synchronously relinquish control to the event loop?
Fulko Hew
fulko.hew at gmail.com
Mon Feb 27 17:01:54 CET 2012
I'm sure this is against AnyEvent's philosophy, but...
I have a timer method that gets woken up periodically to
see if (another applications) data has changed, and if so
it initiates a sequence of events that register a callback
and push_write() something to a remote socket (part 1).
When the response arrives, that callback is execute and it
performs another transaction with the remote socket (part 2).
My issue seems to be that...
because the timer method wakes up and 'processes a file'
the system performs _all_ of the 'part 1' sends first, (and queues
up a lot of outbound traffic) and then, since the file
processing is now complete, and that timer method finally returns...
AnyEvent is now allowed back to its event loop, and can
process all of the 'part 1' responses it receives (that
have been queueing up.
Sortof a:
start ... burstTX... return... burstRx processing... done
And this seems to be causing networking difficulties because
of either the amount of TX queuing, or RX queueing going on.
-----
So my first thought was, how can I, in my part 1 loop, allow
the eventloop to detect and process transmits and receives,
and when idle, let me (my current processing loop) continue?
...some kind of anyevent::allow_eventloop_till_idle() function.
It seems almost as if my main function needs to be broken
into something that gets run a bit at a time, inside
an idle watcher callback, but that's a real pain.
----
My second thought was that somehow Coro can come to my
rescue, but I don't understand how I can merge the two
together, and what I need to do in my mainline and timer callback
to get it to work.
Any help, guidance, direction, or examples would be appreciated.
Fulko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/anyevent/attachments/20120227/ad4873c2/attachment.html>
More information about the anyevent
mailing list