dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
dfx::Core::LocalDestination Class Reference

An in-process destination transport using a thread-safe queue. More...

#include <dfx-core/transports/destinations/LocalDestination.hpp>

Inheritance diagram for dfx::Core::LocalDestination:
[legend]
Collaboration diagram for dfx::Core::LocalDestination:
[legend]

Public Member Functions

void start (FdWatch::Poller &) override
 Activates the transport and begins I/O operations.
void stop () noexcept override
 Deactivates the transport and releases system resources.
bool deliver (MessagePtr message) override
 Pushes the message into the internal synchronous queue.
int64_t pendingMessageCount () const noexcept override
 Returns the current occupancy of the internal queue.
std::optional< MessagePtrpop ()
 Retrieves and removes the oldest message from the queue.
 DestinationTransport (Endpoint endpoint, nlohmann::json config)
 Constructs a DestinationTransport with the Role::Destination role.
Public Member Functions inherited from dfx::Core::DestinationTransport
 DestinationTransport (Endpoint endpoint, nlohmann::json config)
 Constructs a DestinationTransport with the Role::Destination role.
Public Member Functions inherited from dfx::Core::Transport
 Transport (Role role, Endpoint endpoint, nlohmann::json config)
 Constructs a transport instance.
 DFX_DISABLE_COPY_AND_MOVE (Transport)
 Transport is not copiable nor movable.
virtual ~Transport ()=default
 Virtual destructor ensuring proper cleanup of derived transports.
template<DerivedFromTransport T>
bool is () const noexcept
 Check whether this transport is of a given derived type.
template<DerivedFromTransport T>
T & as () noexcept
 Cast this transport to a derived type (unchecked).
template<DerivedFromTransport T>
T const & as () const noexcept
 Cast this transport to a derived type (unchecked).
Role role () const noexcept
 Returns the Role (Source or Destination) of this transport.
bool isSource () const noexcept
 Returns true if this transport is a source.
bool isDestination () const noexcept
 Returns true if this transport is a destination.
Endpoint const & endpoint () const noexcept
 Gets the endpoint descriptor associated with this transport.
Channelchannel () const noexcept
 Gets the channel which this transport is attached to if any.
Portport () const noexcept
 Gets the port associated with this transport.
NodePtr node () const noexcept
 Gets the node associated with this transport.
nlohmann::json const & config () const noexcept
 Gets the JSON configuration used to initialize this transport.

Additional Inherited Members

Public Types inherited from dfx::Core::Transport
enum class  Role { Source , Destination }
 Defines the operational role of a transport relative to a channel. More...
Protected Attributes inherited from dfx::Core::Transport
Role const _role
Endpoint _endpoint
nlohmann::json _config

Detailed Description

An in-process destination transport using a thread-safe queue.

LocalDestination serves as the destination point for InputPort. It stores messages in an internal queue.

Delivery Mechanism
  • When deliver() is called, the message is placed into a fixed-size queue.
  • The InputPort later retrieves the message via pop().
Note
This transport is strictly local; start() and stop() perform no operations.

Member Function Documentation

◆ deliver()

bool dfx::Core::LocalDestination::deliver ( MessagePtr message)
inlineoverridevirtual

Pushes the message into the internal synchronous queue.

Parameters
messageThe message handed over by the Channel.
Returns
true if there was space in the queue; false if full.

Implements dfx::Core::DestinationTransport.

◆ DestinationTransport()

dfx::Core::DestinationTransport::DestinationTransport ( Endpoint endpoint,
nlohmann::json config )
inline

Constructs a DestinationTransport with the Role::Destination role.

Parameters
endpointThe target endpoint descriptor.
configAdditional JSON configuration specific to this transport instance.

◆ pendingMessageCount()

int64_t dfx::Core::LocalDestination::pendingMessageCount ( ) const
inlineoverridevirtualnoexcept

Returns the current occupancy of the internal queue.

Reimplemented from dfx::Core::DestinationTransport.

◆ pop()

std::optional< MessagePtr > dfx::Core::LocalDestination::pop ( )
inline

Retrieves and removes the oldest message from the queue.

Returns
A MessagePtr if the queue was not empty; std::nullopt otherwise.

◆ start()

void dfx::Core::LocalDestination::start ( FdWatch::Poller & poller)
inlineoverridevirtual

Activates the transport and begins I/O operations.

Parameters
pollerThe event loop poller used to watch File Descriptors.

Implements dfx::Core::Transport.

◆ stop()

void dfx::Core::LocalDestination::stop ( )
inlineoverridevirtualnoexcept

Deactivates the transport and releases system resources.

Implements dfx::Core::Transport.


The documentation for this class was generated from the following file: