Any recommendations on where to look to delve into the world of multi-threaded applications? I’d like to really know about how and why things are done before I start blindly using JUCE’s extensive tools for handling threads and stumbling my way to a finished product. I’m about to start on a project involving high-speed data input, GUI and audio output so it seems like a necessary thing to learn before I get stuck in!
Hmmm… obviously multithreading is a HUGE topic and what you want to start with is largely dependent on what you’re working on.
For starters, I’d say the most important things to understand are the concepts behind sharing data across threads and their implications on performance based on availability guarantees. Given that your project involves audio, GUI, and high speed input, you’re really throwing yourself into the deep end!
In terms of hard references, I unfortunately don’t really have any - I was in the same position about two years ago when I started using JUCE and found the best way to learn was to piecemeal my knowledge together by attempting to accomplish certain tasks, getting them somewhat working, running across a tech talk that inspired or directly told me a better way to do it, and improving my knowledge slowly over time.
What I did personally was a lot of practice writing plugins with the
AudioProcessorEditor classes. Learning how to make these classes talk to each other effectively is an excellent way to learn multithreading from the most basic to most advanced levels, since it provides an existing multithread environment (via the external host hosting your plugin) which makes you learn how to synchronize data between an audio thread and a GUI thread of different priorities and update rates, one of which has a near-hard-realtime requirement of NEVER being blocked.
Of course, that approach may be entirely unavailable to you because I don’t know what kind of deadlines you’re under. I’ve spent the last two years aimlessly faffing around since I’m still in school with plenty of time to fool around on the side until things click together.
One talk I watched a lot was this one, which I think is a phenomenal introduction not just to audio as it says in the title, but threading guarantees, locking vs. lock free, and other concepts. Definitely a good place to start.
My favorite talk on parallelization in general is Parallelizing the Naughty Dog Engine Using Fibers, which I’ve watched practically religiously since it came out. Its applications to a beginner in multithreading are probably limited, but shows the limit of what’s possible - Naughty Dog’s game engine is essentially a cooperatively multithreaded operating system running on the PS4.
Ha. Herb’s Atomic Weapons is definitely one of the best talks I’ve seen but not exactly one for the beginner!
Having said that, it’s probably worth watching anyway just to get an idea of the reasons behind all the concurrent methodologies out there. I do constantly refer back to it when dealing with concurrent code…