dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
SPSCChannel.hpp
1// SPDX-FileCopyrightText: 2025 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// Porject includes
12#include "../details/SyncQueue.hpp"
13#include "Channel.hpp"
14
15namespace dfx::Core
16{
44class SPSCChannel : public Channel
45{
46public:
47 using Channel::Channel;
48
49public:
55 bool pushMessage(MessagePtr msg) override;
56
58 bool hasPendingMessage() const override;
59
61 std::size_t pendingMessageCount() const override;
62
69 std::optional<MessagePtr> pop() override;
70
71private:
73};
74} // namespace dfx::Core
Channel(Id id, InputPort &inputPort, OutputPort &outputPort)
Construct a channel linking one input port to one output port.
Bounded SPSC (Single Producer / Single Consumer) channel.
Definition SPSCChannel.hpp:45
std::size_t pendingMessageCount() const override
Number of pending messages currently buffered.
Channel(Id id, InputPort &inputPort, OutputPort &outputPort)
Construct a channel linking one input port to one output port.
bool pushMessage(MessagePtr msg) override
Enqueue a message coming from the producer side.
bool hasPendingMessage() const override
Whether at least one message is pending.
std::optional< MessagePtr > pop() override
Pop the next pending message.
Definition SyncQueue.hpp:51
Definition Channel.hpp:22
std::unique_ptr< Message > MessagePtr
Unique ownership handle for messages.
Definition Message.hpp:27