|
Open Model Railroad Network (OpenMRN)
|
#include "utils/DirectHub.hxx"#include <algorithm>#include <fcntl.h>#include <sys/socket.h>#include <sys/types.h>#include <vector>#include "executor/AsyncNotifiableBlock.hxx"#include "executor/StateFlow.hxx"#include "nmranet_config.h"#include "utils/logging.h"#include "utils/socket_listener.hxx"Go to the source code of this file.
Classes | |
| class | DirectHubService |
| A single service class that is shared between all interconnected DirectHub instances. More... | |
| class | DirectHubImpl< T > |
| class | DirectHubPortSelect |
| Connects a (bytes typed) hub to an FD. More... | |
| class | DirectHubPortSelect::DirectHubReadFlow |
| State flow that reads the FD and sends the read data to the direct hub. More... | |
| struct | DirectHubPortSelect::OutputDataEntry |
| Holds the necessary information we need to keep in the queue about a single output entry. More... | |
| class | DirectGcTcpHub |
Functions | |
| DirectHubInterface< uint8_t[]> * | create_hub (ExecutorBase *e) |
| Temporary function to instantiate the hub. | |
| void | create_port_for_fd (DirectHubInterface< uint8_t[]> *hub, int fd, std::unique_ptr< MessageSegmenter > segmenter, Notifiable *on_error) |
| Creates a hub port of byte stream type reading/writing a given fd. | |
| void | create_direct_gc_tcp_hub (DirectHubInterface< uint8_t[]> *hub, int port) |
| Creates a new GridConnect listener on a given TCP port. | |
Variables | |
| DataBufferPool | g_direct_hub_data_pool (config_directhub_port_incoming_buffer_size()) |
| This object forwards allocations to mainBufferPool. | |
| DataBufferPool | g_direct_hub_kbyte_pool (1024) |
| This object forwards allocations to mainBufferPool. | |
| DirectHubPortSelect * | g_last_direct_hub_port = nullptr |
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Optimized class for ingress and egress of write-once objects, aimed to support multi-recipient messages with fast internal fan-out but low compute overhead.
Definition in file DirectHub.cxx.
| void create_direct_gc_tcp_hub | ( | ByteDirectHubInterface * | hub, |
| int | port | ||
| ) |
Creates a new GridConnect listener on a given TCP port.
The object is leaked (never destroyed).
| hub | incoming and outgoing data will be multiplexed through this hub instance. |
| port | the TCP port to listen on. |
Definition at line 945 of file DirectHub.cxx.
| DirectHubInterface< uint8_t[]> * create_hub | ( | ExecutorBase * | e | ) |
Temporary function to instantiate the hub.
Creates a new byte stream typed hub.
Definition at line 251 of file DirectHub.cxx.
| void create_port_for_fd | ( | ByteDirectHubInterface * | hub, |
| int | fd, | ||
| std::unique_ptr< MessageSegmenter > | segmenter, | ||
| Notifiable * | on_error = nullptr |
||
| ) |
Creates a hub port of byte stream type reading/writing a given fd.
This port will be automaticelly deleted upon any error reading/writing the fd (unregistered and memory released).
| hub | hub instance on which to register the new port. Onwership retained by caller. |
| fd | where to read and write data. |
| segmenter | is an newly allocated object for the given protocol to segment incoming data into messages. Transfers ownership to the function. |
| on_error | this will be notified if the port closes due to an error. |
Definition at line 880 of file DirectHub.cxx.
| DataBufferPool g_direct_hub_data_pool(config_directhub_port_incoming_buffer_size()) | ( | config_directhub_port_incoming_buffer_size() | ) |
This object forwards allocations to mainBufferPool.
The blocks allocated here are all the same size. They are used to read bytes from a tcp socket into memory.
| DataBufferPool g_direct_hub_kbyte_pool(1024) | ( | 1024 | ) |
This object forwards allocations to mainBufferPool.
The blocks allocated here are all the same size. They are used to render outgoing CAN packets into gridconnect format.
| DirectHubPortSelect * g_last_direct_hub_port = nullptr |
Definition at line 878 of file DirectHub.cxx.