clumsy
clumsy copied to clipboard
Scheduling rework
The motivation here is that I want to be able to apply quite low amounts of lag, and variation in lag - and in the current code the value of CLOCK_WAITMS at 40ms, and the associated Sleep(), is high enough to prevent this from being accurate.
Eg if I set lag to 50ms, what I actually see is lag varying from 50-90ms.
So what I've done is this:
- In the first commit on this pull request, simplify the processing so that all interference happens on just one thread
- the thread that reads packets only reads packets and puts them on the queue - it no longer does any processing. Instead it just sets an event to signal to the other thread to indicate that there's work to do.
- that thread wakes up either on timeout or on being signaled, and processes queued packets
- In the second commit, I allow modules to indicate how long a delay they want before being rescheduled, and have the processing thread use a shorter timeout if requested
- in particular,
lagnow indicates when it would like to be rescheduled to send lagged packets - rather than having to wait and be up toCLOCK_WAITMSlate
- in particular,
This version of the pull request is against master - if you take #33, then there's a trivial one-line change needed to lags calculation of the delay. I'd be happy to re-submit this one after #33 is merged, if that's more convenient.
Great I'll be checking this out tomorrow when I get home :)