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_rx_task Class Template Reference

Private server receive thread. More...

Inheritance diagram for s3_txport_tcp_rx_task:

Inheritance graph
[legend]
Collaboration diagram for s3_txport_tcp_rx_task:

Collaboration graph
[legend]
List of all members.

Public Methods

void set_terminate ()
 Post to the termination semaphore. More...

std::string get_message () const
 Return last error message returned by the client. More...

std::string get_client_ip () const
 Returns the IP address of the remote client. More...

bool connected () const
 Returns true if the client is still connected. More...

T_Socket * get_socket ()
 Returns the socket associated with the client. More...

void main_loop ()
 Function that is invoked as the main loop in its own thread. More...


Protected Methods

void cleanup ()
 Cleanup handler. More...

 s3_txport_tcp_rx_task (s3_txport_client_id a_id, T_Socket *a_sock, const std::string &a_client_ip, s3_txport_tcp< T_Data, T_Socket > *a_parent)
 ~s3_txport_tcp_rx_task ()
 Destructor just disconnects the pn from our semaphore. More...


Private Methods

void set_message (const std::string m)

Private Attributes

s3_semaphore sem
 "select()" semaphore. More...

s3_pack_buffer b
 Streamable object for transmission. More...

T_Socket * sock
 The active socket we read from. More...

s3_txport_client_id id
 The ID assigned to this thread. More...

std::string client_ip
 The IP address of the client. More...

std::string message
 The last message returned from the system. More...

bool is_connected
 True if this client is still connected. More...

s3_txport_tcp< T_Data, T_Socket > * parent
 Pointer to parent txport instance. More...

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

s3_periodic_notifier pn
 Periodic notifier to tick system over. More...

s3_mutex c_lock
 Lock for the connection state. More...


Friends

class s3_txport_tcp< T_Data, T_Socket >

Detailed Description

template<class T_Data, class T_Socket>
class s3_txport_tcp_rx_task< T_Data, T_Socket >

Private server receive thread.

This object is the thread associated with each client connection. It can be inspected for all details regarding the connection. It contains a semaphore indicating that this socket is in a critical section, not just this thread. This is to prevent a race condition where a small gap exists between when the connection is tested and data is transmitted in the tx thread. The semaphore is here because this structure is the authority for the connection. Details of the race are documented where it occurs.

Definition at line 289 of file s3_txport_tcp.tcc.


Constructor & Destructor Documentation

template<class T_Data, class T_Socket>
s3_txport_tcp_rx_task< T_Data, T_Socket >::s3_txport_tcp_rx_task s3_txport_client_id    a_id,
T_Socket *    a_sock,
const std::string &    a_client_ip,
s3_txport_tcp< T_Data, T_Socket > *    a_parent
[inline, protected]
 

Definition at line 345 of file s3_txport_tcp.tcc.

References client_ip, id, is_connected, message, s3_txport_client_id, sock, and s3_periodic_notifier::subscribe.

template<class T_Data, class T_Socket>
s3_txport_tcp_rx_task< T_Data, T_Socket >::~s3_txport_tcp_rx_task   [inline, protected]
 

Destructor just disconnects the pn from our semaphore.

Definition at line 356 of file s3_txport_tcp.tcc.

References s3_periodic_notifier::unsubscribe.


Member Function Documentation

template<class T_Data, class T_Socket>
void s3_txport_tcp_rx_task< T_Data, T_Socket >::cleanup   [inline, protected, virtual]
 

Cleanup handler.

This is called before killing the thread, as part of the termination process, once a cancellation request has been received - from stop(). Default implementation does nothing.

Reimplemented from s3_thread_base.

Definition at line 320 of file s3_txport_tcp.tcc.

References s3_periodic_notifier::disable, s3_txport_tcp::dying_tasklets, id, is_connected, s3_mutex::lock, s3_thread_base::lock_state, s3_growable_fifo_queue< s3_txport_client_id >::push, s3_txport_tcp::rx_queue, S3FC_DBG, sock, s3_mutex::unlock, and s3_thread_base::unlock_state.

template<class T_Data, class T_Socket>
bool s3_txport_tcp_rx_task< T_Data, T_Socket >::connected   const [inline]
 

Returns true if the client is still connected.

Definition at line 381 of file s3_txport_tcp.tcc.

References is_connected, s3_mutex::lock, and s3_mutex::unlock.

template<class T_Data, class T_Socket>
std::string s3_txport_tcp_rx_task< T_Data, T_Socket >::get_client_ip   const [inline]
 

Returns the IP address of the remote client.

Definition at line 375 of file s3_txport_tcp.tcc.

References client_ip.

template<class T_Data, class T_Socket>
std::string s3_txport_tcp_rx_task< T_Data, T_Socket >::get_message   const [inline]
 

Return last error message returned by the client.

Definition at line 369 of file s3_txport_tcp.tcc.

References message.

template<class T_Data, class T_Socket>
T_Socket* s3_txport_tcp_rx_task< T_Data, T_Socket >::get_socket   [inline]
 

Returns the socket associated with the client.

Definition at line 391 of file s3_txport_tcp.tcc.

References sock.

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

Function that is invoked as the main loop in its own thread.

Override this in derived class.

Note:
This is to become pure virtual once the older void* main_loop(void*) is dropped entirely.

Implements s3_thread_base.

Definition at line 396 of file s3_txport_tcp.tcc.

References s3_fifo_queue< s3_txport_data< T_Data > >::close_input, s3_event_dispatcher< s3_txport_event >::dispatch_event, s3_periodic_notifier::enable, s3_pack_buffer::get_buffer, id, s3_txport_event::metadata, s3_fifo_queue< s3_txport_data< T_Data > >::nbl_open_input, s3_pack_buffer::reset, s3_txport_tcp::rx_queue, S3FC_DBG, s3_pack_buffer::set_capacity, set_message, sock, s3_semaphore::try_wait, s3_streamable::unpack, and s3_semaphore::wait.

template<class T_Data, class T_Socket>
void s3_txport_tcp_rx_task< T_Data, T_Socket >::set_message const std::string    m [inline, private]
 

Definition at line 314 of file s3_txport_tcp.tcc.

References message.

Referenced by main_loop.

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

Post to the termination semaphore.

Definition at line 363 of file s3_txport_tcp.tcc.

References s3_semaphore::post.


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 477 of file s3_txport_tcp.tcc.


Member Data Documentation

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

Streamable object for transmission.

Definition at line 294 of file s3_txport_tcp.tcc.

template<class T_Data, class T_Socket>
s3_mutex s3_txport_tcp_rx_task::c_lock [private]
 

Lock for the connection state.

Definition at line 312 of file s3_txport_tcp.tcc.

template<class T_Data, class T_Socket>
std::string s3_txport_tcp_rx_task::client_ip [private]
 

The IP address of the client.

Definition at line 300 of file s3_txport_tcp.tcc.

Referenced by get_client_ip, and s3_txport_tcp_rx_task.

template<class T_Data, class T_Socket>
s3_txport_client_id s3_txport_tcp_rx_task::id [private]
 

The ID assigned to this thread.

Definition at line 298 of file s3_txport_tcp.tcc.

Referenced by cleanup, main_loop, and s3_txport_tcp_rx_task.

template<class T_Data, class T_Socket>
bool s3_txport_tcp_rx_task::is_connected [private]
 

True if this client is still connected.

Definition at line 304 of file s3_txport_tcp.tcc.

Referenced by cleanup, connected, and s3_txport_tcp_rx_task.

template<class T_Data, class T_Socket>
std::string s3_txport_tcp_rx_task::message [private]
 

The last message returned from the system.

Definition at line 302 of file s3_txport_tcp.tcc.

Referenced by get_message, s3_txport_tcp_rx_task, and set_message.

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

Pointer to parent txport instance.

Definition at line 306 of file s3_txport_tcp.tcc.

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

Periodic notifier to tick system over.

Definition at line 310 of file s3_txport_tcp.tcc.

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

"select()" semaphore.

Definition at line 292 of file s3_txport_tcp.tcc.

template<class T_Data, class T_Socket>
T_Socket* s3_txport_tcp_rx_task::sock [private]
 

The active socket we read from.

Definition at line 296 of file s3_txport_tcp.tcc.

Referenced by cleanup, get_socket, main_loop, and s3_txport_tcp_rx_task.

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

Set to true if we must terminate the thread.

Definition at line 308 of file s3_txport_tcp.tcc.


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