Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
graph_thread.h
1// SPDX-FileCopyrightText: © 2019-2021, 2024 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "zrythm-config.h"
7
8#include "utils/rt_thread_id.h"
9
10#include "juce_wrapper.h"
11
12namespace zrythm::dsp::graph
13{
14
15class GraphScheduler;
16
20class GraphThread final : public juce::Thread
21{
22public:
31 explicit GraphThread (
32 int id,
33 bool is_main,
34 GraphScheduler &scheduler,
35 std::optional<juce::AudioWorkgroup> workgroup = std::nullopt);
36 ~GraphThread () override;
37
38public:
46 [[gnu::hot]] void on_reached_terminal_node ();
47
48private:
49 void run () override;
50
54 void run_worker () noexcept [[clang::nonblocking]];
55
56public:
62 int id_{ -1 };
63
64 bool is_main_{ false };
65
69 std::atomic<RTThreadId::IdType> rt_thread_id_{ 0 };
70
73
79 std::optional<juce::AudioWorkgroup> audio_workgroup_;
80
81private:
86 std::atomic<bool> thread_finished_{ false };
87};
88
89} // namespace zrythm::dsp::graph
Manages the scheduling and execution of a graph of DSP nodes.
std::atomic< RTThreadId::IdType > rt_thread_id_
Realtime thread ID.
int id_
Thread index in zrythm.
GraphScheduler & scheduler_
Pointer back to the owner scheduler.
std::optional< juce::AudioWorkgroup > audio_workgroup_
Non-owning pointer (optional) to a workgroup to join.
void on_reached_terminal_node()
Called to indicate a terminal node has completed processing.
GraphThread(int id, bool is_main, GraphScheduler &scheduler, std::optional< juce::AudioWorkgroup > workgroup=std::nullopt)
Creates and starts a realtime thread.