std::async in cpp with background thread loading data example | Introduction to Concurrency in C++

  Рет қаралды 10,446

Mike Shah

Mike Shah

Күн бұрын

►Full Series Playlist: • Modern C++ (cpp) Concu...
►Find full courses on: courses.mshah.io/
►Join as Member to Support the channel: / @mikeshah
►Git Repo: github.com/MikeShah/moderncpp...
►Lesson Description: In this lesson I show you an example with std::async and how you can use it to load data in a background thread. We also discuss the policies that exist for how to launch a std::async, and look at the futures library to get the status of our future.
00:00 Return to async
00:20 Real world example with KZfaq
1:45 Program design with background thread
2:50 Starting our program
3:37 Discussion of std::async policies
4:50 Setting up our background thread
5:50 Understanding future_status
6:30 The main program loop
8:45 Checking status of future
10:02 Implementing our background thread
12:00 Compilation and bug fixes
12:40 Successful execution of the program
14:50 Conclusion, like, and subscribe!
►KZfaq Channel: / mikeshah
►Please like and subscribe to help the channel!

Пікірлер: 28
@PaulMetalhero
@PaulMetalhero Жыл бұрын
Exactly what I needed for my game engine. Thank you!
@MikeShah
@MikeShah Жыл бұрын
Cheers!
@sinaezar5402
@sinaezar5402 9 ай бұрын
very useful and practical, thank you for tutorial.
@MikeShah
@MikeShah 9 ай бұрын
Cheers!
@nemolovie1715
@nemolovie1715 2 жыл бұрын
Good videos man, very nice, I like to hear more about this topic and other c++ topics
@MikeShah
@MikeShah 2 жыл бұрын
Thank you for the kind words!
@aarfeenanees9147
@aarfeenanees9147 Жыл бұрын
That was really helpful, thanks!
@MikeShah
@MikeShah Жыл бұрын
Cheers!
@randomWork111
@randomWork111 Жыл бұрын
Thank you so much Prof
@MikeShah
@MikeShah Жыл бұрын
Cheers!
@abba5102
@abba5102 2 жыл бұрын
Very good brother
@MikeShah
@MikeShah 2 жыл бұрын
Cheers!
@HungrySpikeShorts
@HungrySpikeShorts Жыл бұрын
Thx You So Much Bro!!!! :)
@MikeShah
@MikeShah Жыл бұрын
Enjoy!
@peter03192003
@peter03192003 Жыл бұрын
Thank you :)
@MikeShah
@MikeShah Жыл бұрын
You are most welcome! Thank you for the generous support!
@dolevdo
@dolevdo 2 жыл бұрын
Thank you a lot!
@MikeShah
@MikeShah 2 жыл бұрын
You are most welcome!
@robertstrickland9722
@robertstrickland9722 Жыл бұрын
Great stuff Mike! Any future, no pun intended, videos to cover expanding upon async with the std::promise ?
@MikeShah
@MikeShah Жыл бұрын
Thanks Robert! Probably at some point, I think the next lessons for this series will either cover some patterns, or otherwise lower level primitives (latches, semaphores, etc.)
@aarfeenanees9147
@aarfeenanees9147 Жыл бұрын
3:50 Alexanderescu's book is two decades old, is it still relevant now?
@MikeShah
@MikeShah Жыл бұрын
Still worth reading in my opinion -- will help you understand how many libraries are designed
@davidpinheiro5295
@davidpinheiro5295 5 ай бұрын
If no policy is provided, is async or deferred the default? Is this implementation dependent?
@MikeShah
@MikeShah 5 ай бұрын
I think the behavior is undefined -- so std::launch::async or std::launch::deferred should be specified.
@windowsbuilderthegreat3121
@windowsbuilderthegreat3121 10 ай бұрын
Is there a way to make this type of concurrently parallel in c++ like with async await in c#
@MikeShah
@MikeShah 10 ай бұрын
The thread may be launched on a new thread to achieve parallelism.
@vengeance3223
@vengeance3223 9 ай бұрын
Do the threads in the video not run parallel?
@MikeShah
@MikeShah 9 ай бұрын
​@@vengeance3223I believe they are -- but it is possible the os schedules them to run the same thread if there is little work to be done.
Задержи дыхание дольше всех!
00:42
Аришнев
Рет қаралды 3,7 МЛН
Идеально повторил? Хотите вторую часть?
00:13
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 6 МЛН
How one thread listens to many sockets with select in C.
12:01
Jacob Sorber
Рет қаралды 96 М.
C# Async Await Mistakes | Part 1
10:19
Amichai Mantinband
Рет қаралды 32 М.
Why You Shouldn't Nest Your Code
8:30
CodeAesthetic
Рет қаралды 2,6 МЛН
Llama 3.1 Talks to your Database with Open Interpreter
2:39
Bluetooth connected successfully 💯💯
0:16
Blue ice Comedy
Рет қаралды 1,2 МЛН
Это - iPhone 16!
16:29
Rozetked
Рет қаралды 138 М.