S3FC project page | S3FC home page |
#include <s3_txport_local.h>
Inheritance diagram for s3_txport_local:
Public Methods | |
s3_txport_local (unsigned int queue_size=4) | |
Constructor. More... | |
~s3_txport_local () | |
Destructor. More... | |
s3_fifo_queue< s3_txport_data< T_Data > > & | get_tx_queue () |
Return a reference to a s3_fifo_queue specialised on the s3_txport_data for the transmit data queue. More... | |
s3_fifo_queue< s3_txport_data< T_Data > > & | get_rx_queue () |
Return a reference to a s3_fifo_queue specialised on the s3_txport_data for the received data queue. More... | |
std::list< s3_txport_client_id > | get_client_id_list () const |
Returns a list of all currently connected clients. More... | |
void | send_metadata (s3_txport_client_id id, const std::string &metadata) |
Transmit metadata to the remote connection. More... | |
bool | is_connected_by_id (s3_txport_client_id id) |
Returns true if the client is still considered to be active. More... | |
bool | disconnect_by_id (s3_txport_client_id id) |
Disconnect the indicated remote connection. More... | |
void | disconnect_all () |
Disconnect all clients, regardless, but keep the listener etc. alive. More... | |
bool | listening () const |
Returns true if the server is listening for connections. More... | |
s3_txport_client_id | connect (s3_txport_local< T_Data > *listener) |
Make a connection to a s3_txport_local listener. More... | |
bool | listen () |
Set up a listener (effectively a switch) to which other s3_txports_local can connect. More... | |
void | main_loop () |
Function that is invoked as the main loop in its own thread. More... | |
int | num_connections () const |
returns the current number of connections. More... | |
Private Types | |
typedef std::map< s3_txport_client_id, s3_txport_local< T_Data > * > | c_map |
Type to mutually map txports to each other. More... | |
Private Methods | |
s3_txport_local * | register_me (s3_txport_local *remote) |
Register this transport with the remote transport. More... | |
void | deregister_me (const s3_txport_local *remote) |
Deregister an instance of a local transport with this instance. More... | |
s3_txport_client_id | next_id () |
Increment the connection id. It is always non-zero for valid connections. More... | |
void | cleanup () |
Code to clean up if the thread. More... | |
Private Attributes | |
s3_fifo_queue< s3_txport_data< T_Data > > | rx_queue |
Queue from which the data will be read. More... | |
s3_fifo_queue< s3_txport_data< T_Data > > | tx_queue |
Queue in which to write data to be sent to a client. More... | |
s3_semaphore | terminate |
Post to this to terminate the listener thread. More... | |
s3_semaphore | sem |
Semaphore used to signal various activities. More... | |
s3_txport_client_id | connect_id |
Counter to ensure unique connection IDs. More... | |
c_map | connections |
Map the client connection ID to the client's queue. More... | |
s3_periodic_notifier | pn |
Blipper to keep the listener thread from blocking. More... | |
s3_mutex | connection_mutex |
Static state mutex to protect the connection structure. More... |
This class allows threads to connect to each other via queues, in a similar fasion to the tcp transports. Individual transports are able to connect to each other and to set up listeners, analogous to servers. It behaves in the same way as the s3_txport_tcp class.
Definition at line 52 of file s3_txport_local.h.
|
Type to mutually map txports to each other.
Definition at line 70 of file s3_txport_local.h. |
|
Constructor.
Definition at line 33 of file s3_txport_local.tcc. References s3_thread_base::start. |
|
Destructor.
Definition at line 40 of file s3_txport_local.tcc. References disconnect_all, s3_thread_base::is_running, s3_semaphore::post, terminate, and s3_thread_base::wait_on_exit. |
|
Code to clean up if the thread.
Reimplemented from s3_thread_base. Definition at line 238 of file s3_txport_local.tcc. References s3_periodic_notifier::disable, pn, S3FC_DBG, sem, tx_queue, and s3_periodic_notifier::unsubscribe. |
|
Make a connection to a s3_txport_local listener. Currently, only one connection is allowed per pair of transports. The connection will fail if you are already talking to the desitination. This behavior may change in the future.
Definition at line 146 of file s3_txport_local.tcc. References s3_txport_event::connect, connection_mutex, connections, s3_event_dispatcher< s3_txport_event >::dispatch_event, s3_txport_event::error, s3_mutex::lock, next_id, register_me, s3_txport_client_id, and s3_mutex::unlock. |
|
Deregister an instance of a local transport with this instance.
Definition at line 205 of file s3_txport_local.tcc. References connection_mutex, connections, s3_txport_event::disconnect, s3_event_dispatcher< s3_txport_event >::dispatch_event, s3_mutex::lock, and s3_mutex::unlock. |
|
Disconnect all clients, regardless, but keep the listener etc. alive.
Implements s3_txport_base. Definition at line 125 of file s3_txport_local.tcc. References connections, and disconnect_by_id. Referenced by ~s3_txport_local. |
|
Disconnect the indicated remote connection.
Implements s3_txport_base. Definition at line 103 of file s3_txport_local.tcc. References connection_mutex, connections, s3_txport_event::disconnect, s3_event_dispatcher< s3_txport_event >::dispatch_event, s3_mutex::lock, s3_txport_client_id, and s3_mutex::unlock. Referenced by disconnect_all. |
|
Returns a list of all currently connected clients. Note that this list reflects the situation at the time of the call, and there is no guarantee that all the clients in the list are connected. Messages to unconnected clients are simply driopped. Implements s3_txport_base. Definition at line 64 of file s3_txport_local.tcc. References connection_mutex, connections, s3_mutex::lock, and s3_mutex::unlock. |
|
Return a reference to a s3_fifo_queue specialised on the s3_txport_data for the received data queue.
Implements s3_txport_base. Definition at line 57 of file s3_txport_local.tcc. References rx_queue. |
|
Return a reference to a s3_fifo_queue specialised on the s3_txport_data for the transmit data queue.
Implements s3_txport_base. Definition at line 51 of file s3_txport_local.tcc. References tx_queue. |
|
Returns true if the client is still considered to be active.
Implements s3_txport_base. Definition at line 93 of file s3_txport_local.tcc. References connection_mutex, connections, s3_mutex::lock, s3_txport_client_id, and s3_mutex::unlock. |
|
Set up a listener (effectively a switch) to which other s3_txports_local can connect.
Definition at line 232 of file s3_txport_local.tcc. |
|
Returns true if the server is listening for connections.
Implements s3_txport_base. Definition at line 140 of file s3_txport_local.tcc. References s3_thread_base::is_running. |
|
Function that is invoked as the main loop in its own thread. Override this in derived class.
Implements s3_thread_base. Definition at line 248 of file s3_txport_local.tcc. References s3_fifo_queue< s3_txport_data< T_Data > >::close_output, connection_mutex, connections, s3_event_dispatcher< s3_txport_event >::dispatch_event, s3_periodic_notifier::enable, s3_txport_event::error, s3_mutex::lock, s3_fifo_queue< s3_txport_data< T_Data > >::nbl_open_output, pn, sem, s3_periodic_notifier::subscribe, terminate, s3_semaphore::try_wait, tx_queue, s3_mutex::unlock, and s3_semaphore::wait. |
|
Increment the connection id. It is always non-zero for valid connections.
Definition at line 96 of file s3_txport_local.h. References connect_id, and s3_txport_client_id. Referenced by connect, and register_me. |
|
returns the current number of connections.
Definition at line 292 of file s3_txport_local.tcc. References connection_mutex, connections, s3_mutex::lock, and s3_mutex::unlock. |
|
Register this transport with the remote transport.
Definition at line 173 of file s3_txport_local.tcc. References s3_txport_event::connect, connection_mutex, connections, s3_event_dispatcher< s3_txport_event >::dispatch_event, s3_txport_event::error, s3_mutex::lock, next_id, s3_txport_client_id, and s3_mutex::unlock. Referenced by connect. |
|
Transmit metadata to the remote connection. The metadata will be dispatched to any s3_event_handler types attached to the s3_txport_base.
Implements s3_txport_base. Definition at line 78 of file s3_txport_local.tcc. References connection_mutex, connections, s3_mutex::lock, s3_txport_event::metadata, s3_txport_client_id, and s3_mutex::unlock. |
|
Counter to ensure unique connection IDs.
Definition at line 67 of file s3_txport_local.h. Referenced by next_id. |
|
Static state mutex to protect the connection structure.
Definition at line 79 of file s3_txport_local.h. Referenced by connect, deregister_me, disconnect_by_id, get_client_id_list, is_connected_by_id, main_loop, num_connections, register_me, and send_metadata. |
|
Map the client connection ID to the client's queue.
Definition at line 73 of file s3_txport_local.h. Referenced by connect, deregister_me, disconnect_all, disconnect_by_id, get_client_id_list, is_connected_by_id, main_loop, num_connections, register_me, and send_metadata. |
|
Blipper to keep the listener thread from blocking.
Definition at line 76 of file s3_txport_local.h. |
|
Queue from which the data will be read.
Definition at line 55 of file s3_txport_local.h. Referenced by get_rx_queue. |
|
Semaphore used to signal various activities.
Definition at line 64 of file s3_txport_local.h. |
|
Post to this to terminate the listener thread.
Definition at line 61 of file s3_txport_local.h. Referenced by main_loop, and ~s3_txport_local. |
|
Queue in which to write data to be sent to a client.
Definition at line 58 of file s3_txport_local.h. Referenced by cleanup, get_tx_queue, and main_loop. |
Send comments to: s3fc@stonethree.com |
|