#include <delaychan.h>
Inheritance diagram for PAdaptiveDelay:
Public Member Functions | |
Operating Parameters | |
void | SetMaximumSlip (PTimeInterval maximumSlip) |
PTimeInterval | GetMaximumSlip () const |
Functionality | |
PBoolean | Delay (int time) |
void | Restart () |
Protected Attributes | |
PBoolean | firstTime |
PTime | targetTime |
PTimeInterval | jitterLimit |
PTimeInterval | minimumDelay |
PAdaptiveDelay::PAdaptiveDelay | ( | unsigned | maximumSlip = 0 , |
|
unsigned | minimumDelay = 0 | |||
) |
Create a new adaptive delay with the specified parameters.
The maximum slip time can also be set later using SetMaximumSlip.
maximumSlip | Maximum slip time in milliseconds |
minimumDelay | Minimum delay (usually OS time slice) |
PAdaptiveDelay::PAdaptiveDelay | ( | unsigned | maximumSlip = 0 , |
|
unsigned | minimumDelay = 0 | |||
) |
Create a new adaptive delay with the specified parameters.
The maximum slip time can also be set later using SetMaximumSlip.
maximumSlip | Maximum slip time in milliseconds |
minimumDelay | Minimum delay (usually OS time slice) |
void PAdaptiveDelay::SetMaximumSlip | ( | PTimeInterval | maximumSlip | ) | [inline] |
Set the number of milliseconds that the delay may "catch up" by using zero delays. This is caused by the Delay() function not being called for a time by external factors.
If maximumSlip is 0, this feature is disabled.
PTimeInterval PAdaptiveDelay::GetMaximumSlip | ( | ) | const [inline] |
Get the current slip time.
PBoolean PAdaptiveDelay::Delay | ( | int | time | ) |
Wait until the specified number of milliseconds have elapsed from the previous call (on average). The first time the function is called, no delay occurs. If the maximum slip time is set and the caller is "too late", the timer is restarted automatically and no delay occurs.
If the calculated delay is less than the OS timer resolution specified on costruction, no delay occurs now ("better sooner than later" strategy).
void PAdaptiveDelay::Restart | ( | ) |
Invalidate the timer. The timing of this function call is not important, the timer will restart at the next call to Delay().
PBoolean PAdaptiveDelay::firstTime [protected] |
PTime PAdaptiveDelay::targetTime [protected] |
PTimeInterval PAdaptiveDelay::jitterLimit [protected] |
PTimeInterval PAdaptiveDelay::minimumDelay [protected] |