dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
ThreadBased.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// Standard includes
12#include <thread>
13
14// Project includes
15#include <dfx-core/Node.hpp>
16
17namespace dfx::Node
18{
19class ThreadBased : public Core::Node
20{
21public:
22 ThreadBased(std::string type, Id id, std::string name);
23 ~ThreadBased() override;
24
25protected:
26 void startImpl() override;
27 void stopImpl() override;
28
29 virtual void exec(std::stop_token stopToken) = 0;
30
31protected:
34
35private:
36 std::atomic_bool _isInDtor{false};
37 std::jthread _thread;
38};
39} // !namespace dfx::Core
Base class for all runtime-executed nodes in a dfx dataflow graph.
Incoming message endpoint attached to a node.
Definition InputPort.hpp:55
Abstract base class for all nodes in the dfx runtime.
Definition Node.hpp:91
ExecutionFlowPolicy
Policy controlling how execution is chained after message delivery.
Definition Node.hpp:106
uint32_t Id
Node identifier type (unique and stable within a graph instance).
Definition Node.hpp:113
std::string const & name() const noexcept
Get the node name.
Definition Node.hpp:134
std::string const & type() const noexcept
Get the node type.
Definition Node.hpp:132
void handleMessage(Core::InputPort const &, Core::MessagePtr) override
Handle an incoming message on an input port.
Definition ThreadBased.hpp:33
void setExecutionFlowPolicy(ExecutionFlowPolicy) override
Set the execution flow policy used by the runtime scheduler.
void stopImpl() override
Called by stop before the node is marked stopped.
void startImpl() override
Called by start before the node is marked running.
std::unique_ptr< Message > MessagePtr
Unique ownership handle for messages.
Definition Message.hpp:27
Definition MimeTypeRouter.hpp:18