Can I synchronously relinquish control to the event loop?

Dirk Koopman djk at tobit.co.uk
Mon Feb 27 19:04:12 CET 2012


I have a huge legacy app which has  "mop up" function currently called 
in a timed loop. Ideally this should be in the idle loop, but then the 
idle loop consumes the entire CPU.

I need to run this timed loop no more than 20 times a second (in fact 10 
times would be adequate). This loop process may queue up data for output 
or may consume data that has come in, but does not do any I/O or other 
stuff that would involve AE during loop time.

Unfortunately, there seems to be no obvious way of making sure that 
nothing else is happening in AE when the timed loop happens and this 
will, very occasionally, cause spurious error messages from places which 
don't seem to make much sense. Doesn't stop working, but I know I will 
get complaints when these messages are seen in the log.

What I would like is a "timed" idle loop callback. A loop which is 
called whenever AE is truly idle, but only up to a maximum of so many 
per second. There need be no guarantee of being called the full (or even 
any) of that no of times, but AE *must* be truly idle.

Dirk



More information about the anyevent mailing list