dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
ThreadBased.hpp
1// SPDX-FileCopyrightText: 2025-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 <thread>
13
14// Project includes
15#include <dfx-core/CustomExecutor.hpp>
16#include <dfx-core/Node.hpp>
17
18namespace dfx::Node
19{
20class ThreadBased : public Core::Node
21{
22public:
23 ThreadBased(std::string type, Id id, std::string name);
24 ~ThreadBased() override;
25
26protected:
27 void startImpl() override;
28 void stopImpl() override;
29
30 virtual void exec(std::stop_token stopToken) = 0;
31
32 void tick();
33
34protected:
37
38private:
39 std::atomic_bool _isInDtor{false};
40 std::jthread _thread;
41};
42} // !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:57
Abstract base class for all nodes in the dfx runtime.
Definition Node.hpp:94
ExecutionFlowPolicy
Policy controlling how execution is chained after message delivery.
Definition Node.hpp:109
uint32_t Id
Node identifier type (unique and stable within a graph instance).
Definition Node.hpp:116
std::string const & name() const noexcept
Get the node name.
Definition Node.hpp:137
std::string const & type() const noexcept
Get the node type.
Definition Node.hpp:135
void handleMessage(Core::InputPort const &, Core::MessagePtr) override
Handle an incoming message on an input port.
Definition ThreadBased.hpp:36
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