class BufferedAsyncReader


 
LOGO
 Annotated List  Files  Globals  Hierarchy  Index  Top

Public Types

Public Methods


Detailed Description

enum Event { DATA = 1, OS_ERROR = 2, END_OF_FILE = 3 }

Event

typedef XorpCallback4<void, BufferedAsyncReader*, Event, uint8_t*, size_t>::RefPtr Callback

Callback

 BufferedAsyncReader (EventLoop& e, XorpFd fd, size_t reserve_bytes, const Callback& cb)

BufferedAsyncReader

Constructor.

Parameters:

ethe eventloop.
fdthe file descriptor.
reserve_bytesthe number of bytes to reserve in the data buffer.
cbthe callback to invoke.
 ~BufferedAsyncReader ()

~BufferedAsyncReader

bool  set_trigger_bytes (size_t bytes)

set_trigger_bytes

Set threshold for event notification. Only when this threshold is reached the consumers callback invoked. If more data is already available, then the event notification will be triggered through a 0 second timer. This provides an opportunity for other tasks to run.

Calling this method may cause the internal buffer state to change. If it is called from within a consumer callback, then the buffer pointer may become invalid and dereferencing the pointer should be avoided.

Parameters:

bytesthe number of threshold bytes.

Returns: true on success, false if bytes is larger than reserve.

size_t  trigger_bytes ()

trigger_bytes

[const]

Get the current threshold for event notification.

bool  dispose (size_t bytes)

dispose

Acknowledge data at the start of the buffer is finished with.

Typically, a consumer would call this from within their callback to say this number of bytes has been processed and can be discarded.

Parameters:

bytesthe number of bytes to dispose.

Returns: true on success, false if bytes is larger than the number of available bytes.

bool  set_reserve_bytes (size_t bytes)

set_reserve_bytes

Set reserve for maximum amount of data to receive.

Parameters:

bytesthe number of bytes to reserve.

Returns: true on success, false if error.

size_t  reserve_bytes ()

reserve_bytes

[const]

Get reserve for maximum amount of data to receive.

size_t  available_bytes ()

available_bytes

[const]

Get the number of currently available bytes.

inline int  error ()

error

[const]

void  start ()

start

Start.

Start asynchrous reads.

void  stop ()

stop

Stop.

Stop asynchrous reading.


Generated by: pavlin on possum.icir.org on Wed Aug 2 15:35:43 2006, using kdoc $.