xorp

AsyncFileReader Class Reference

Read asynchronously from a file. More...

#include <asyncio.hh>

Inheritance diagram for AsyncFileReader:
AsyncFileOperator

List of all members.

Classes

class  BufferInfo

Public Member Functions

 AsyncFileReader (EventLoop &e, XorpFd fd, int priority=XorpTask::PRIORITY_DEFAULT)
void add_buffer (uint8_t *buffer, size_t buffer_bytes, const Callback &cb)
 Add an additional buffer for reading to.
void add_buffer_with_offset (uint8_t *buffer, size_t buffer_bytes, size_t offset, const Callback &cb)
 Add an additional buffer for reading to.
bool start ()
 Start asynchronous operation.
void stop ()
 Stop asynchronous operation.
size_t buffers_remaining () const
void flush_buffers ()
 Stop asynchronous operation and clear list of buffers.
virtual string toString () const

Protected Member Functions

void read (XorpFd fd, IoEventType type)
void complete_transfer (int err, ssize_t done)

Protected Attributes

list< BufferInfo * > _buffers

Detailed Description

Read asynchronously from a file.


Constructor & Destructor Documentation

AsyncFileReader::AsyncFileReader ( EventLoop e,
XorpFd  fd,
int  priority = XorpTask::PRIORITY_DEFAULT 
)
Parameters:
eEventLoop that object should associate itself with.
fda file descriptor to read from.

Member Function Documentation

void AsyncFileReader::add_buffer ( uint8_t *  buffer,
size_t  buffer_bytes,
const Callback cb 
)

Add an additional buffer for reading to.

Note that the buffer with the data is managed by the user.

Parameters:
bufferpointer to buffer.
buffer_bytessize of buffer in bytes.
cbCallback object to invoke when I/O is performed.
void AsyncFileReader::add_buffer_with_offset ( uint8_t *  buffer,
size_t  buffer_bytes,
size_t  offset,
const Callback cb 
)

Add an additional buffer for reading to.

Note that the buffer with the data is managed by the user.

Parameters:
bufferpointer to buffer.
buffer_bytessize of buffer in bytes.
offsetstarting point for read operation.
cbCallback object to invoke when I/O is performed.
size_t AsyncFileReader::buffers_remaining ( ) const [inline, virtual]
Returns:
the number of buffers available.

Implements AsyncFileOperator.

bool AsyncFileReader::start ( ) [virtual]

Start asynchronous operation.

Returns:
true on success, false if no buffers are available.

Implements AsyncFileOperator.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations