S3FC project page S3FC home page

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

s3_txport_tcp_tx_task Class Template Reference

TCP send thread, used internally by the server class. More...

Inheritance diagram for s3_txport_tcp_tx_task:

Inheritance graph
[legend]
Collaboration diagram for s3_txport_tcp_tx_task:

Collaboration graph
[legend]
List of all members.

Public Methods

void main_loop ()
 Main thread loop, not to be called. More...

void set_terminate ()

Private Methods

 s3_txport_tcp_tx_task (s3_fifo_queue< s3_txport_data< T_Data > > &a_q, s3_txport_tcp< T_Data, T_Socket > *a_parent)
 Default constructor. More...

 ~s3_txport_tcp_tx_task ()
 Destructor. More...

void handle_failure (s3_txport_client_id id, std::string err_msg)
 Routine to handle failures detected by the tcp system. More...

void cleanup ()
 Clean up the odds and ends we started. More...


Private Attributes

s3_semaphore sem
 The semaphore which signals the various events. More...

s3_fifo_queue< s3_txport_data<
T_Data > > & 
in_q
 Queue for data received. More...

s3_pack_buffer b
 Streamable buffer for POD, as all data must be serialised. More...

s3_txport_tcp< T_Data, T_Socket > * parent
 Parent server thread. More...

s3_semaphore terminate
 Set to true if we must terminate the thread. More...

s3_periodic_notifier pn
 Periodic notifier for our "select()" and timeout. More...

std::list< s3_txport_client_idid_list
 Internal list needed to track where to send data in broadcasts. More...


Friends

class s3_txport_tcp< T_Data, T_Socket >

Detailed Description

template<class T_Data, class T_Socket>
class s3_txport_tcp_tx_task< T_Data, T_Socket >

TCP send thread, used internally by the server class.

This class waits on a queue for data to be sent to a designated client that is currently connected to the server. The queue data type is of s3_txport_data and contains both an s3_streamable payload as well as an s3_txport_client_id indicating the desired destination for the payload. If the designated client has closed the connection, the payload is dropped and the offending client is earmarked for termination. The error is reported by the s3_event_dispatcher() mechanism. This thread is responsible for reaping rx threads earmarked for termination. The thread runs under an s3_periodic_notifier() to ensure that it is woken up to reap the dead tasks, irrespective of inputs to the queue. If this thread blocks in the tcp_send function, then it will not reap dead connections and things will get stuck.

Definition at line 65 of file s3_txport_tcp.tcc.


Constructor & Destructor Documentation

template<class T_Data, class T_Socket>
s3_txport_tcp_tx_task< T_Data, T_Socket >::s3_txport_tcp_tx_task s3_fifo_queue< s3_txport_data< T_Data > > &    a_q,
s3_txport_tcp< T_Data, T_Socket > *    a_parent
[private]
 

Default constructor.

Definition at line 117 of file s3_txport_tcp.tcc.

References pn, sem, s3_periodic_notifier::set_period, and s3_periodic_notifier::subscribe.

template<class T_Data, class T_Socket>
s3_txport_tcp_tx_task< T_Data, T_Socket >::~s3_txport_tcp_tx_task   [inline, private]
 

Destructor.

Definition at line 87 of file s3_txport_tcp.tcc.


Member Function Documentation

template<class T_Data, class T_Socket>
void s3_txport_tcp_tx_task< T_Data, T_Socket >::cleanup   [private, virtual]
 

Clean up the odds and ends we started.

Reimplemented from s3_thread_base.

Definition at line 128 of file s3_txport_tcp.tcc.

References s3_periodic_notifier::disable, in_q, parent, pn, and sem.

template<class T_Data, class T_Socket>
void s3_txport_tcp_tx_task< T_Data, T_Socket >::handle_failure s3_txport_client_id    id,
std::string    err_msg
[inline, private]
 

Routine to handle failures detected by the tcp system.

Definition at line 93 of file s3_txport_tcp.tcc.

Referenced by main_loop.

template<class T_Data, class T_Socket>
void s3_txport_tcp_tx_task< T_Data, T_Socket >::main_loop   [virtual]
 

Main thread loop, not to be called.

Implements s3_thread_base.

Definition at line 136 of file s3_txport_tcp.tcc.

References b, s3_fifo_queue< s3_txport_data< T_Data > >::close_output, s3_periodic_notifier::enable, s3_txport_event::error, s3_pack_buffer::get_buffer, s3_pack_buffer::get_size, handle_failure, id_list, in_q, s3_fifo_queue< s3_txport_data< T_Data > >::nbl_open_output, s3_streamable::pack, parent, pn, s3_pack_buffer::reset, s3_txport_client_id, S3FC_DBG, sem, terminate, s3_semaphore::try_wait, and s3_semaphore::wait.

template<class T_Data, class T_Socket>
void s3_txport_tcp_tx_task< T_Data, T_Socket >::set_terminate   [inline]
 

Definition at line 108 of file s3_txport_tcp.tcc.


Friends And Related Function Documentation

template<class T_Data, class T_Socket>
friend class s3_txport_tcp< T_Data, T_Socket > [friend]
 

Definition at line 113 of file s3_txport_tcp.tcc.


Member Data Documentation

template<class T_Data, class T_Socket>
s3_pack_buffer s3_txport_tcp_tx_task::b [private]
 

Streamable buffer for POD, as all data must be serialised.

Definition at line 72 of file s3_txport_tcp.tcc.

Referenced by main_loop.

template<class T_Data, class T_Socket>
std::list<s3_txport_client_id> s3_txport_tcp_tx_task::id_list [private]
 

Internal list needed to track where to send data in broadcasts.

Definition at line 80 of file s3_txport_tcp.tcc.

Referenced by main_loop.

template<class T_Data, class T_Socket>
s3_fifo_queue<s3_txport_data<T_Data> >& s3_txport_tcp_tx_task::in_q [private]
 

Queue for data received.

Definition at line 70 of file s3_txport_tcp.tcc.

Referenced by cleanup, and main_loop.

template<class T_Data, class T_Socket>
s3_txport_tcp<T_Data, T_Socket>* s3_txport_tcp_tx_task::parent [private]
 

Parent server thread.

Definition at line 74 of file s3_txport_tcp.tcc.

Referenced by cleanup, and main_loop.

template<class T_Data, class T_Socket>
s3_periodic_notifier s3_txport_tcp_tx_task::pn [private]
 

Periodic notifier for our "select()" and timeout.

Definition at line 78 of file s3_txport_tcp.tcc.

Referenced by cleanup, main_loop, and s3_txport_tcp_tx_task.

template<class T_Data, class T_Socket>
s3_semaphore s3_txport_tcp_tx_task::sem [private]
 

The semaphore which signals the various events.

Definition at line 68 of file s3_txport_tcp.tcc.

Referenced by cleanup, main_loop, and s3_txport_tcp_tx_task.

template<class T_Data, class T_Socket>
s3_semaphore s3_txport_tcp_tx_task::terminate [private]
 

Set to true if we must terminate the thread.

Definition at line 76 of file s3_txport_tcp.tcc.

Referenced by main_loop.


The documentation for this class was generated from the following file:
Send comments to: s3fc@stonethree.com SourceForge Logo