dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
LocalDestination.hpp
1// SPDX-FileCopyrightText: 2026 Vincent Leroy
2// SPDX-License-Identifier: MIT
3//
4// This file is part of dfx.
5//
6// Licensed under the MIT License. See the LICENSE file in the project root
7// for full license information.
8
9#pragma once
10
11// Standard includes
12#include <optional>
13
14// Project includes
15#include "DestinationTransport.hpp"
16#include <dfx-utilities/sync-queues/SpscFixedQueue.hpp>
17
18namespace dfx::Core
19{
34{
35public:
37
38public:
39 void start(FdWatch::Poller &) override {}
40 void stop() noexcept override {}
41
47 bool deliver(MessagePtr message) override
48 { return _pendingMessages.tryPush(std::move(message)); }
49
51 int64_t pendingMessageCount() const noexcept override
52 { return static_cast<int64_t>(_pendingMessages.size()); }
53
54public:
58 std::optional<MessagePtr> pop()
59 { return _pendingMessages.tryPop(); }
60
61private:
63};
64} // !namespace dfx::Core
DestinationTransport(Endpoint endpoint, nlohmann::json config)
Constructs a DestinationTransport with the Role::Destination role.
Definition DestinationTransport.hpp:32
An in-process destination transport using a thread-safe queue.
Definition LocalDestination.hpp:34
int64_t pendingMessageCount() const noexcept override
Returns the current occupancy of the internal queue.
Definition LocalDestination.hpp:51
std::optional< MessagePtr > pop()
Retrieves and removes the oldest message from the queue.
Definition LocalDestination.hpp:58
bool deliver(MessagePtr message) override
Pushes the message into the internal synchronous queue.
Definition LocalDestination.hpp:47
void stop() noexcept override
Deactivates the transport and releases system resources.
Definition LocalDestination.hpp:40
DestinationTransport(Endpoint endpoint, nlohmann::json config)
Constructs a DestinationTransport with the Role::Destination role.
Definition DestinationTransport.hpp:32
void start(FdWatch::Poller &) override
Activates the transport and begins I/O operations.
Definition LocalDestination.hpp:39
Abstract interface for FD-based event polling.
Definition Poller.hpp:37
A high-performance, lock-free, Single-Producer Single-Consumer (SPSC) bounded queue.
Definition SpscFixedQueue.hpp:47
Definition Channel.hpp:25
std::unique_ptr< Message > MessagePtr
Unique ownership handle for messages.
Definition Message.hpp:27