freesecs::async_reception_t Class Reference

Asyncronous read from a file descriptor The class implements async read from file descriptor using POSIX select. The read is done in a separate thread with the signal triggered when all the requested data comes. There's only one thread started per multiple async_reception_t instances, with refcount, to exit when the last async_reception_t gets destroyed. The new async_reception_t gets created, FDSET is updated and the thread is notified to call select against an updated FDSET. More...

#include <async_reception.h>

Collaboration diagram for freesecs::async_reception_t:

Collaboration graph
[legend]
List of all members.

Public Types

enum  state_t { IDLE = 0, WTG_FOR_DATA, RECEIVED }
 data reception state define

Public Member Functions

 async_reception_t (int fd, const char *name)
 ctor
virtual ~async_reception_t ()
void start_recv (void *buf, size_t count)
 Starts receiving data Having been specified the buffer location and number of bytes to read, async reader instance proceeds to WTG_FOR_DATA state until all the data comes as requested and then proceeds to RECEIVED state. When all data has been read, data_recvd_signal is triggered. When data is partially read, data_partially_recvd_signal is triggered. When reception error occurs (socket cnx has been closed or nothing else is to be read), recv_error_signal is triggered.
void stop_recv ()
 Stops recieving data.
state_t get_state ()
 Returns status of data recieving.
size_t get_bytes_read ()
 Returns number of bytes received since last start_recv call.

Public Attributes

signal_one_arg_t< size_t > data_partially_recvd_signal
 Signal for reception/read activity.
signal_one_arg_t< size_t > data_recvd_signal
 Signal for data received as per start_recv request.
signal_one_arg_t< int > recv_error_signal
 Signal for data reception/read error The reasons could be: tcp disconnect, EOF. The argiment of the signal is error code as per errno spec.

Classes

union  event_data_t
 Async SM event type declaration.

Detailed Description

Asyncronous read from a file descriptor The class implements async read from file descriptor using POSIX select. The read is done in a separate thread with the signal triggered when all the requested data comes. There's only one thread started per multiple async_reception_t instances, with refcount, to exit when the last async_reception_t gets destroyed. The new async_reception_t gets created, FDSET is updated and the thread is notified to call select against an updated FDSET.

Definition at line 43 of file async_reception.h.


Constructor & Destructor Documentation

freesecs::async_reception_t::async_reception_t ( int  fd,
const char *  name 
)

ctor

Parameters:
fd File descriptor to read from
name async reception instance name, used for logging

Definition at line 45 of file async_reception.cpp.

References async_reception_t().

Referenced by async_reception_t().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

void freesecs::async_reception_t::start_recv ( void *  buf,
size_t  count 
)

Starts receiving data Having been specified the buffer location and number of bytes to read, async reader instance proceeds to WTG_FOR_DATA state until all the data comes as requested and then proceeds to RECEIVED state. When all data has been read, data_recvd_signal is triggered. When data is partially read, data_partially_recvd_signal is triggered. When reception error occurs (socket cnx has been closed or nothing else is to be read), recv_error_signal is triggered.

Parameters:
buf Buffer to store data into
count Number of bytes to read

Definition at line 110 of file async_reception.cpp.

Referenced by freesecs::ms_timer_t::start().

Here is the caller graph for this function:

size_t freesecs::async_reception_t::get_bytes_read (  ) 

Returns number of bytes received since last start_recv call.

See also:
start_recv

Definition at line 134 of file async_reception.cpp.


Member Data Documentation

signal_one_arg_t<size_t> freesecs::async_reception_t::data_partially_recvd_signal

Signal for reception/read activity.

See also:
signal_one_arg_t

Definition at line 99 of file async_reception.h.

signal_one_arg_t<size_t> freesecs::async_reception_t::data_recvd_signal

Signal for data received as per start_recv request.

See also:
start_recv

Definition at line 104 of file async_reception.h.

Referenced by freesecs::ms_timer_t::ms_timer_t().


The documentation for this class was generated from the following files:
Generated on Fri Oct 3 15:30:07 2008 for FREESECS hsms by  doxygen 1.5.1