An helper class for Endpoint implementations which implements some common basic functionality. More...
#include <BasicEndpoint.h>

Public Member Functions | |
| bool | IsRunning () |
| Checks whether the endpoint has been started. More... | |
| virtual void | Send (data::Message *message, const Node *node) override |
| Send a message to a specific member of the swarm. Call with node set to nullptr to send a message to all members of the swarm. More... | |
| virtual void | Start () override |
| Start a background thread and begin processing messages on this endpoint. More... | |
| virtual void | Stop () override |
| Send a termination signal and wait until the endpoint finished processing messages. More... | |
| virtual void | Tag (data::Message *message) override |
| Set the message identifier for a message. More... | |
Public Member Functions inherited from swarmio::Endpoint | |
| virtual const std::string & | GetUUID ()=0 |
| Get the UUID of the local node. More... | |
| virtual const Node * | NodeForUUID (const std::string &uuid)=0 |
| Retreive a node by its UUID. More... | |
| virtual | ~Endpoint () |
| Destroy the Endpoint object. More... | |
Protected Member Functions | |
| BasicEndpoint () | |
| Protected constructor. More... | |
| virtual void | NodeDidJoin (const Node *node) noexcept |
| Called when a new Node has joined the group. More... | |
| virtual void | NodeWasDiscovered (const Node *node) noexcept |
| Called when a new Node has been discovered. More... | |
| virtual void | NodeWillLeave (const Node *node) noexcept |
| Called when a Node signals that it will leave. More... | |
| virtual bool | ReceiveMessage (const Node *sender, const data::Message *message) noexcept |
| Called by implementations to deliver decoded messages. More... | |
| virtual bool | ReceiveMessage (const Node *sender, const void *data, size_t size) noexcept |
| Called by implementations to deliver raw messages. More... | |
| virtual void | RegisterMailbox (Mailbox *mailbox) override |
| Register a Mailbox to receive messages. More... | |
| virtual void | ReplaceMailbox (Mailbox *oldMailbox, Mailbox *newMailbox) override |
| Relocate a mailbox to another in-memory location. More... | |
| virtual void | Send (const void *data, size_t size, const Node *node)=0 |
| Called by this class to send serialized messages. Called with node set to nullptr to send a message to all members of the swarm. More... | |
| virtual void | UnregisterMailbox (Mailbox *mailbox) override |
| Unregister a Mailbox from receiving messages. More... | |
Private Member Functions | |
| void | ReplyWithError (const Node *sender, const data::Message *message, data::Error error) |
| Send a reply to a message that only contains a status code. More... | |
Private Attributes | |
| std::atomic< uint64_t > | _counter |
| Atomic counter for message identifiers. More... | |
| bool | _isRunning |
| True if the Mailbox has been started. More... | |
| std::set< Mailbox * > | _mailboxes |
| Container for registered mailboxes. More... | |
| std::recursive_mutex | _mutex |
| Mutex used to synchronize access to the list of mailboxes. More... | |
Additional Inherited Members | |
Protected Attributes inherited from swarmio::Endpoint | |
| friend | Mailbox |
| Allow Mailboxes to register themselves. More... | |
An helper class for Endpoint implementations which implements some common basic functionality.
Definition at line 15 of file BasicEndpoint.h.
|
inlineprotected |
Protected constructor.
Definition at line 57 of file BasicEndpoint.h.
|
inline |
Checks whether the endpoint has been started.
Definition at line 162 of file BasicEndpoint.h.
|
protectedvirtualnoexcept |
Called when a new Node has joined the group.
| node | The node that has been discovered |
Definition at line 102 of file BasicEndpoint.cpp.
|
protectedvirtualnoexcept |
Called when a new Node has been discovered.
| node | The node that has been discovered |
Definition at line 91 of file BasicEndpoint.cpp.
|
protectedvirtualnoexcept |
Called when a Node signals that it will leave.
| node | The node that has left |
Definition at line 113 of file BasicEndpoint.cpp.
|
protectedvirtualnoexcept |
Called by implementations to deliver decoded messages.
| sender | Sender node |
| message | The message itself |
Definition at line 155 of file BasicEndpoint.cpp.
|
protectedvirtualnoexcept |
Called by implementations to deliver raw messages.
| sender | Sender node |
| data | Raw message data |
| size | Length of the message data |
Definition at line 124 of file BasicEndpoint.cpp.
|
overrideprotectedvirtual |
Register a Mailbox to receive messages.
May be called more than once, and has no effect if the mailbox has already been registered.
| mailbox | Mailbox to register. |
Implements swarmio::Endpoint.
Definition at line 54 of file BasicEndpoint.cpp.
|
overrideprotectedvirtual |
Relocate a mailbox to another in-memory location.
Supports thread-safe move operations on Mailboxes.
| mailbox | Mailbox to register. |
Implements swarmio::Endpoint.
Definition at line 82 of file BasicEndpoint.cpp.
|
private |
Send a reply to a message that only contains a status code.
| sender | Sender of the original message |
| message | The original message |
| error | Error code to send back |
Definition at line 138 of file BasicEndpoint.cpp.
|
protectedpure virtual |
Called by this class to send serialized messages. Called with node set to nullptr to send a message to all members of the swarm.
| data | Raw message data |
| size | Length of the message data |
| node | Node the message will be sent to |
Implemented in swarmio::transport::zyre::ZyreEndpoint.
|
overridevirtual |
Send a message to a specific member of the swarm. Call with node set to nullptr to send a message to all members of the swarm.
Thread-safe.
| message | Message |
| node | Node the message will be sent to |
Implements swarmio::Endpoint.
Definition at line 228 of file BasicEndpoint.cpp.
|
overridevirtual |
Start a background thread and begin processing messages on this endpoint.
Implements swarmio::Endpoint.
Reimplemented in swarmio::transport::zyre::ZyreEndpoint.
Definition at line 11 of file BasicEndpoint.cpp.
|
overridevirtual |
Send a termination signal and wait until the endpoint finished processing messages.
Thread-safe.
Implements swarmio::Endpoint.
Reimplemented in swarmio::transport::zyre::ZyreEndpoint.
Definition at line 32 of file BasicEndpoint.cpp.
|
overridevirtual |
Set the message identifier for a message.
Thread safe.
| message | Message |
Implements swarmio::Endpoint.
Definition at line 218 of file BasicEndpoint.cpp.
|
overrideprotectedvirtual |
Unregister a Mailbox from receiving messages.
May be called more than once, and has no effect if the mailbox has already been unregistered.
| mailbox | Mailbox to unregister. |
Implements swarmio::Endpoint.
Definition at line 68 of file BasicEndpoint.cpp.
|
private |
Atomic counter for message identifiers.
Definition at line 40 of file BasicEndpoint.h.
|
private |
True if the Mailbox has been started.
Definition at line 23 of file BasicEndpoint.h.
Container for registered mailboxes.
Definition at line 28 of file BasicEndpoint.h.
|
private |
Mutex used to synchronize access to the list of mailboxes.
Definition at line 34 of file BasicEndpoint.h.