# PDelayChannel Class Reference

Class for implementing a "delay line" channel. More...

`#include <delaychan.h>`

Inheritance diagram for PDelayChannel:

List of all members.

## Construction

enum | Mode { DelayReadsOnly, DelayWritesOnly, DelayReadsAndWrites }
| PDelayChannel (Mode mode, unsigned frameDelay, PINDEX frameSize=0, unsigned maximumSlip=250, unsigned minimumDelay=10)
| Create a new delay channel with the specified delays.
| PDelayChannel (PChannel &channel, Mode mode, unsigned frameDelay, PINDEX frameSize=0, unsigned maximumSlip=250, unsigned minimumDelay=10)
| Create a new delay channel with the specified delays and channel.

## Public Member Functions

Overrides from class PChannel
virtual PBoolean | Read (void *buf, PINDEX len)
| Low level read from the file channel.
virtual PBoolean | Write (const void *buf, PINDEX len)
| Low level write to the file channel.

## Protected Member Functions

virtual void | Wait (PINDEX count, PTimeInterval &nextTick)

## Protected Attributes

Mode | mode
unsigned | frameDelay
PINDEX | frameSize
PTimeInterval | maximumSlip
PTimeInterval | minimumDelay
PTimeInterval | nextReadTick
PTimeInterval | nextWriteTick

## Detailed Description

Class for implementing a "delay line" channel.

This indirect channel can be placed in a channel I/O chain to limit the speed of I/O. This can be useful if blocking is not available and buffers could be overwritten if the I/O occurs at full speed.

There are two modes of operation. In stream more, data can be read/written no faster than a fixed time for a fixed number of bytes. So, for example, you can say than 320 bytes must take 20 milliseconds, and thus if the application writes 640 byets it will delay 40 milliseconds before the next write.

In frame mode, the rate limiting applies to individual read or write operations. So you can say that each read takes 30 milliseconds even if on 4 bytes is read, and the same time if 24 bytes are read.

## Member Enumeration Documentation

enum PDelayChannel::Mode

Enumerator:

  DelayReadsOnly |
  DelayWritesOnly |
  DelayReadsAndWrites |

## Constructor & Destructor Documentation

PDelayChannel::PDelayChannel | ( | Mode | mode,
|  | unsigned | frameDelay,
|  | PINDEX | frameSize = `0`,
|  | unsigned | maximumSlip = `250`,
|  | unsigned | minimumDelay = `10` |
| ) |  |  |

Create a new delay channel with the specified delays.

A value of zero for the numBytes parameter indicates that the delay is in frame mode.

The maximum skip time is the number of milliseconds that the delay may "catch up" by using zero delays. This is caused by the Read() or Write() not being called for a time by external factors.

Parameters:

  mode | Mode for delay channel
  frameDelay | Delay time in milliseconds
  frameSize | Bytes to apply to the delay time.
  maximumSlip | Maximum slip time in milliseconds
  minimumDelay | Minimim delay (usually OS time slice)

PDelayChannel::PDelayChannel | ( | PChannel & | channel,
|  | Mode | mode,
|  | unsigned | frameDelay,
|  | PINDEX | frameSize = `0`,
|  | unsigned | maximumSlip = `250`,
|  | unsigned | minimumDelay = `10` |
| ) |  |  |

Create a new delay channel with the specified delays and channel.

A value of zero for the numBytes parameter indicates that the delay is in frame mode.

The maximum skip time is the number of milliseconds that the delay may "catch up" by using zero delays. This is caused by the Read() or Write() not being called for a time by external factors.

Parameters:

  channel | channel to use
  mode | Mode for delay channel
  frameDelay | Delay time in milliseconds
  frameSize | Bytes to apply to the delay time.
  maximumSlip | Maximum slip time in milliseconds
  minimumDelay | Minimim delay (usually OS time slice)

## Member Function Documentation

virtual PBoolean PDelayChannel::Read | ( | void * | buf,
|  | PINDEX | len |
| ) |  |  | `[virtual]`

Low level read from the file channel.

The read timeout is ignored for file I/O. The GetLastReadCount() function returns the actual number of bytes read.

The GetErrorCode() function should be consulted after Read() returns false to determine what caused the failure.

Returns:
  true indicates that at least one character was read from the channel. false means no bytes were read due to timeout or some other I/O error.

Parameters:

  buf | Pointer to a block of memory to receive the read bytes.
  len | Maximum number of bytes to read into the buffer.

Reimplemented from PIndirectChannel.

Reimplemented in PVXMLChannel.

virtual void PDelayChannel::Wait | ( | PINDEX | count,
|  | PTimeInterval & | nextTick |
| ) |  |  | `[protected, virtual]`

virtual PBoolean PDelayChannel::Write | ( | const void * | buf,
|  | PINDEX | len |
| ) |  |  | `[virtual]`

Low level write to the file channel.

The write timeout is ignored for file I/O. The GetLastWriteCount() function returns the actual number of bytes written.

The GetErrorCode() function should be consulted after Write() returns false to determine what caused the failure.

Returns:
  true if at least len bytes were written to the channel.

Parameters:

  buf | Pointer to a block of memory to write.
  len | Number of bytes to write.

Reimplemented from PIndirectChannel.

Reimplemented in PVXMLChannel.

## Member Data Documentation

unsigned PDelayChannel::frameDelay `[protected]`

PINDEX PDelayChannel::frameSize `[protected]`

PTimeInterval PDelayChannel::maximumSlip `[protected]`

PTimeInterval PDelayChannel::minimumDelay `[protected]`

Mode PDelayChannel::mode `[protected]`

PTimeInterval PDelayChannel::nextReadTick `[protected]`

PTimeInterval PDelayChannel::nextWriteTick `[protected]`

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

- delaychan.h