UI Thread vs Audio Thread (c++ nodes)
-
Is it possible / straightforward to use the Hise threading system inside of a c++ node?
I have a node that occasionally does heavy offline computations which will potentially choke the audio thread / eat up all the CPU headroom. I'm talking about stuff such as doing fft on a long audio file, or generating mipmaps for wavetables. It would be nice to run these on a less critical thread.
I suppose a workaround would be to do any heavy calculations in small blocks,
tackling a single block per iteration. But that seems a little wasteful.Alternatively:
juce::ThreadPool ?
What would you recommend @Christoph-Hart ?
: ) -
I don't think you can safely hook into the threading model of HISE with its dedicated loading / scripting threads as they don't work across DLL boundaries, but you can always spawn your own thread if you want to perform heavyweight tasks.
I would just use the
juce::Thread
class to spawn a thread that performs the operation. Just make sure you are synchronizing the data access correctly so you don't end up with race conditions. -
Thanks I'll look into it!
-
G griffinboy marked this topic as a question
-
G griffinboy has marked this topic as solved