PTLib Version 2.12.9

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Protected Attributes | List of all members
PAdaptiveDelay Class Reference

Class for implementing an "adaptive" delay. More...

`#include <delaychan.h>`

Inheritance diagram for PAdaptiveDelay:
[legend]
Collaboration diagram for PAdaptiveDelay:
[legend]

## Public Member Functions
Construction
| PAdaptiveDelay (unsigned maximumSlip=0, unsigned minimumDelay=0)
| Create a new adaptive delay with the specified parameters. More...
Operating Parameters
void | SetMaximumSlip (unsigned maximumSlip)
| Set the number of milliseconds that the delay may "catch up" by using zero delays. More...
PTimeInterval | GetMaximumSlip () const
| Get the current slip time. More...
Functionality
PBoolean | Delay (int time)
| Wait until the specified number of milliseconds have elapsed from the previous call (on average). More...
void | Restart ()
| Invalidate the timer. More...
Public Member Functions inherited from PObject
unsigned | GetTraceContextIdentifier () const
| Get PTRACE context identifier. More...
void | SetTraceContextIdentifier (unsigned id)
void | GetTraceContextIdentifier (PObject &obj)
void | GetTraceContextIdentifier (PObject *obj)
void | SetTraceContextIdentifier (const PObject &obj)
void | SetTraceContextIdentifier (const PObject *obj)
virtual | ~PObject ()
virtual PObject * | Clone () const
| Create a copy of the class on the heap. More...
template<class CLS >
CLS * | CloneAs () const
| As for Clone() but converts to specified type. More...
virtual PINDEX | HashFunction () const
| This function yields a hash value required by the `PDictionary` class. More...
virtual Comparison | Compare (const PObject &obj) const
| Compare the two objects and return their relative rank. More...
virtual Comparison | CompareObjectMemoryDirect (const PObject &obj) const
| Determine the byte wise comparison of two objects. More...
bool | operator== (const PObject &obj) const
| Compare the two objects. More...
bool | operator!= (const PObject &obj) const
| Compare the two objects. More...
bool | operator< (const PObject &obj) const
| Compare the two objects. More...
bool | operator> (const PObject &obj) const
| Compare the two objects. More...
bool | operator<= (const PObject &obj) const
| Compare the two objects. More...
bool | operator>= (const PObject &obj) const
| Compare the two objects. More...
virtual const char * | GetClass (unsigned ancestor=0) const
| Get the current dynamic type of the object instance. More...
PBoolean | IsClass (const char *cls) const
virtual PBoolean | InternalIsDescendant (const char *clsName) const
| Determine if the dynamic type of the current instance is a descendent of the specified class. More...
__inline const PObject * | PTraceObjectInstance () const
virtual void | PrintOn (ostream &strm) const
| Output the contents of the object to the stream. More...
virtual void | ReadFrom (istream &strm)
| Input the contents of the object from the stream. More...

## Protected Attributes
PTimeInterval | m_jitterLimit
PTimeInterval | m_minimumDelay
PTime | m_targetTime
bool | m_firstTime
Protected Attributes inherited from PObject
unsigned | m_traceContextIdentifier

## Additional Inherited Members
Public Types inherited from PObject
enum | Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }
| Result of the comparison operation performed by the `Compare()` function. More...
Static Public Member Functions inherited from PObject
static Comparison | InternalCompareObjectMemoryDirect (const PObject *obj1, const PObject *obj2, PINDEX size)
| Internal function caled from CompareObjectMemoryDirect() More...
static const char * | Class ()
| Get the name of the class as a C string. More...
static __inline const PObject * | PTraceObjectInstance (const char *)
static __inline const PObject * | PTraceObjectInstance (const PObject *obj)
Protected Member Functions inherited from PObject
| PObject ()
| Constructor for PObject, made protected so cannot ever create one on its own. More...
Friends inherited from PObject

## Detailed Description

Class for implementing an "adaptive" delay.

This class will cause the the caller to, on average, delay the specified number of milliseconds between calls. This can be used to simulate hardware timing for a sofwtare only device

## Constructor & Destructor Documentation

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.

Parameters

  maximumSlip | Maximum slip time in milliseconds
  minimumDelay | Minimum delay (usually OS time slice)

## Member Function Documentation

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).

Returns
  true if we are "too late" of time milliseconds (unrelated to the maximum slip time).

PTimeInterval PAdaptiveDelay::GetMaximumSlip | ( |  | ) | const
| inline

Get the current slip time.

References m_jitterLimit.

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().

void PAdaptiveDelay::SetMaximumSlip | ( | unsigned | 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.

References m_jitterLimit.

## Member Data Documentation

bool PAdaptiveDelay::m_firstTime
| protected

PTimeInterval PAdaptiveDelay::m_jitterLimit
| protected

Referenced by GetMaximumSlip(), and SetMaximumSlip().

PTimeInterval PAdaptiveDelay::m_minimumDelay
| protected

PTime PAdaptiveDelay::m_targetTime
| protected

The documentation for this class was generated from the following file:

- delaychan.h