S3FC project page | S3FC home page |
#include <s3_message.h>
Inheritance diagram for s3_post_office:
Public Methods | |
~s3_post_office () | |
The destructor, cleans up the conn now. More... | |
s3_post_office () | |
Instantiate a post office. More... | |
void | connect (const std::string &ip, int port) |
Connect to the post office switch listening at the specified port and IP address. More... | |
void | disconnect () |
Disconnect from the post office switch. More... | |
void | add_dst (const std::string &dst, s3_message_box &mbox, bool is_group) |
Associate the destination address dst with the client mbox and the specified destination type. More... | |
void | remove_dst (const std::string &dst, s3_message_box &mbox, bool is_group) |
Remove the association between destination address dst and the client mbox . More... | |
virtual void | main_loop () |
Read the demultiplex all messages that arrive from the switch (i.e. More... | |
Protected Methods | |
void | dispatch_msg (const s3_message &msg, s3_message_box &mbox) |
Accept a message from an s3_message_box and enqueue it for distribution. More... | |
bool | is_connected () const |
Return the connection status. More... | |
bool | add_dst_switch (const std::string &name, bool is_group) |
Send a request to the switch to add an association between the specified destination name and this instance. More... | |
bool | remove_dst_switch (const std::string &name, bool is_group) |
Send a request to the switch to remove the association between the specified name and the connection to this instance. More... | |
void | deliver_all_but_one (const s3_message &msg, const std::list< s3_message_box * > &clients, const s3_message_box *except) |
Deliver a message to all clients except one. More... | |
std::string | get_next_message_id () |
Return the next message id in the sequence. More... | |
Private Attributes | |
s3_txport_tcp< s3_message > * | conn |
Physical (TCP/IP) connection endpoint. More... | |
s3_txport_client_id | conn_id |
Connection ID of the connection to the Post Office Switch. More... | |
std::map< std::string, dst_data > | dst_map |
The destination map: destination name to client list and destination type. More... | |
s3_fifo_queue< s3_message > | ctrl_rx_queue |
Control RX queue - all received control messages end up here. More... | |
s3_fifo_queue< client_msg > | client_rx_queue |
Queue containing messages dispatched by clients. More... | |
int | seq_nr |
Sequence count used to generate message IDs. More... | |
s3_mutex | dst_lock |
Lock that guards entire critical sections of operations that add or remove destinations. More... | |
s3_semaphore | started |
Semaphore used to synchronise startup. More... | |
Friends | |
class | s3_message_box |
Each instance executes as a thread with a main event loop that sevices the client connections and the connection to the Post Office Switch. The destination
map is implemented as an STL map
from string
(destination address) to dst_data
(structure containing an STL list
of s3_message_box*
and a bool
indicating whether it is a group address. The physical connection between a s3_post_office
and a Post Office Switch implementation, s3_post_office_switch
, is accomplished using a s3_txport_tcp<s3_message>
, operating as a client (i.e. connected), in the s3_post_office
.
Definition at line 712 of file s3_message.h.
|
The destructor, cleans up the conn now.
Definition at line 556 of file s3_message.cc. References disconnect, and is_connected. |
|
Instantiate a post office.
Definition at line 547 of file s3_message.cc. |
|
Associate the destination address
Definition at line 653 of file s3_message.cc. References add_dst_switch, dst_lock, dst_map, is_connected, s3_mutex::lock, s3_thread_base::lock_state, s3_mutex::unlock, and s3_thread_base::unlock_state. Referenced by s3_message_box::connect, and s3_message_box::subscribe_group. |
|
Send a request to the switch to add an association between the specified destination name and this instance.
The name is checked for uniqueness if is not a group name. The operation fails if a name clash is detected. This uses the
Definition at line 979 of file s3_message.cc. References conn, conn_id, s3_message::CONTROL, ctrl_rx_queue, s3_message::get_body, s3_message::get_debug_str, get_next_message_id, s3_txport_tcp< s3_message >::get_tx_queue, s3_inplace_fifo_base< s3_message >::pop, and S3FC_DBG. Referenced by add_dst. |
|
Connect to the post office switch listening at the specified port and IP address.
If the connection succeeds, the main event loop is started. This call only returns after successful startup, i.e. when the event loop is running. This throws an
Definition at line 599 of file s3_message.cc. References conn, conn_id, s3_txport_tcp< s3_message >::connect, s3_txport_tcp< s3_message >::is_connected_by_id, s3_thread_base::start, started, and s3_semaphore::wait. Referenced by s3_message_box::init. |
|
Deliver a message to all clients except one.
Definition at line 1035 of file s3_message.cc. References S3FC_DBG. Referenced by main_loop. |
|
Disconnect from the post office switch.
Fail if any clients are still registered. The main event loop is stopped and the connection to the Definition at line 627 of file s3_message.cc. References conn, dst_map, s3_txport_tcp< s3_message >::stop, and s3_thread_base::wait_on_exit. Referenced by s3_message_box::de_init, and ~s3_post_office. |
|
Accept a message from an
Definition at line 965 of file s3_message.cc. References client_rx_queue, and s3_inplace_fifo_base< client_msg >::push. Referenced by s3_message_box::reply_msg, and s3_message_box::send_msg. |
|
Return the next message id in the sequence.
Definition at line 1056 of file s3_message.cc. References seq_nr. Referenced by add_dst_switch, and remove_dst_switch. |
|
Return the connection status.
Definition at line 972 of file s3_message.cc. References conn, conn_id, and s3_txport_tcp< s3_message >::is_connected_by_id. Referenced by add_dst, s3_message_box::initialised, main_loop, remove_dst, and ~s3_post_office. |
|
|
Remove the association between destination address
Definition at line 707 of file s3_message.cc. References dst_lock, dst_map, is_connected, s3_mutex::lock, s3_thread_base::lock_state, remove_dst_switch, s3_mutex::unlock, and s3_thread_base::unlock_state. Referenced by s3_message_box::disconnect, and s3_message_box::unsubscribe_group. |
|
Send a request to the switch to remove the association between the specified name and the connection to this instance.
This uses the
Definition at line 1008 of file s3_message.cc. References conn, conn_id, s3_message::CONTROL, ctrl_rx_queue, s3_message::get_body, s3_message::get_debug_str, get_next_message_id, s3_txport_tcp< s3_message >::get_tx_queue, s3_inplace_fifo_base< s3_message >::pop, and S3FC_DBG. Referenced by remove_dst. |
|
Definition at line 714 of file s3_message.h. |
|
Queue containing messages dispatched by clients.
Definition at line 774 of file s3_message.h. Referenced by dispatch_msg, and main_loop. |
|
Physical (TCP/IP) connection endpoint.
Definition at line 754 of file s3_message.h. Referenced by add_dst_switch, connect, disconnect, is_connected, main_loop, and remove_dst_switch. |
|
Connection ID of the connection to the Post Office Switch.
Definition at line 760 of file s3_message.h. Referenced by add_dst_switch, connect, is_connected, main_loop, and remove_dst_switch. |
|
Control RX queue - all received control messages end up here. It is a free-for-all queue that can be accessed by all member functions. Definition at line 770 of file s3_message.h. Referenced by add_dst_switch, main_loop, and remove_dst_switch. |
|
Lock that guards entire critical sections of operations that add or remove destinations.
This does not lock the Definition at line 786 of file s3_message.h. Referenced by add_dst, and remove_dst. |
|
The destination map: destination name to client list and destination type.
Definition at line 765 of file s3_message.h. Referenced by add_dst, disconnect, main_loop, and remove_dst. |
|
Sequence count used to generate message IDs.
Definition at line 778 of file s3_message.h. Referenced by get_next_message_id. |
|
Semaphore used to synchronise startup.
Reimplemented from s3_thread_base. Definition at line 790 of file s3_message.h. |
Send comments to: s3fc@stonethree.com |
|