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#ifndef ZRYTHM_DSP_GRAPH_THREAD_H
5#define ZRYTHM_DSP_GRAPH_THREAD_H
6
7#include "zrythm-config.h"
8
9#include "utils/rt_thread_id.h"
10
11#include "juce_wrapper.h"
12
13namespace zrythm::dsp::graph
14{
15
16class GraphScheduler;
17
21class GraphThread final : public juce::Thread
22{
23public:
32 explicit GraphThread (
33 int id,
34 bool is_main,
35 GraphScheduler &scheduler,
36 std::optional<juce::AudioWorkgroup> workgroup = std::nullopt);
37 ~GraphThread () override;
38
39public:
47 [[gnu::hot]] void on_reached_terminal_node ();
48
49private:
50 void run () override;
51
55 void run_worker () noexcept [[clang::nonblocking]];
56
57public:
63 int id_{ -1 };
64
65 bool is_main_{ false };
66
70 std::atomic<RTThreadId::IdType> rt_thread_id_{ 0 };
71
74
80 std::optional<juce::AudioWorkgroup> audio_workgroup_;
81
82private:
87 std::atomic<bool> thread_finished_{ false };
88};
89
90} // namespace zrythm::dsp::graph
91
92#endif
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.