Multithreading/Concurrency with C++ Threads - Creating, and Communicating with Background Threads

preview_player
Показать описание
In this video we use the C++ threads library to accomplish a few different task with threads. We create a few worker threads, to break down some work into various parallel chunks. We look at how to run some heavier tasks in the background in short and long running threads, and also how to safely share data and communicate between threads using std::mutex, std::scoped_lock and std::conditional_variable.

00:00 - Intro
01:32 - C++ & CMake Setup
02:08 - Application Explanation
04:18 - Drawing Code
06:13 - Starting a std::thread
06:46 - join() and detach() an std::thread
07:56 - How many threads to create?
09:42 - Core utilization
10:08 - Using std::hardware_concurrency()
11:26 - Multithreaded drawing
15:15 - Saving data with a background thread
16:20 - Using detach()
16:57 - Using std::future and std::async
18:20 - std::mutex explanation
20:19 - Save data code
20:43 - std::scoped_lock explanation
23:23 - UI updates in a multithreaded application
25:49 - Quick explanation on deadlocks
27:03 - Loading data with a long running thread
29:17 - std::condition_variable explanation and usage
30:28 - std::unique_lock

Here's the code:
Рекомендации по теме
Комментарии
Автор

Wow, how does this not have more views!! Such a well put together video, thank you for sharing!

doctordeak
Автор

Really good and concise explanations. Thank you for making this 🙂

tesla
Автор

so you had 8 possible threads and used it all? what about operating system and other programs running beside your program?

sepidehsoleimani
Автор

That was pretty awesome. Thank you so much. I am looking for great channels on C++ programming to refresh knowledge, catch up, and get up to date with C++ features from basic to advanced presented in an uncomplicated way. This video was clear and concise packing a lot into 30 minutes. I loved it and I have subscribed. I will definitely check all the other content. Nota bene--you have lambda misspelled on your slide as "labmda" and in the video description you probably want plural "tasks" in first sentence 🙂...just paying attention to detail, or trying to... 🤣

palrevesz
join shbcf.ru