clumsy icon indicating copy to clipboard operation
clumsy copied to clipboard

Scheduling rework

Open dimbleby opened this issue 9 years ago • 1 comments

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, lag now indicates when it would like to be rescheduled to send lagged packets - rather than having to wait and be up to CLOCK_WAITMS late

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.

dimbleby avatar Jul 29 '16 11:07 dimbleby

Great I'll be checking this out tomorrow when I get home :)

jagt avatar Jul 29 '16 17:07 jagt