Master Multithreading : Thread Pool In C++

  Рет қаралды 14,868

CppNuts

CppNuts

Күн бұрын

Пікірлер: 34
@hyesungmoon4750
@hyesungmoon4750 9 ай бұрын
You are so good at explaining the code. This video is really helpful. Appreciate your time and effort to create this video!
@aaryaguru4732
@aaryaguru4732 10 ай бұрын
Thank so much for making understanding each and every line of code along with OS concept😊😊
@firstnamelastname-tr8fo
@firstnamelastname-tr8fo 10 ай бұрын
Thank you for the tutorial. I would like to know how one could receive the return value of a task or wait for a specific task to finish before proceeding.
@CppNuts
@CppNuts 10 ай бұрын
promise And future In C++ kzbin.info/www/bejne/jnW9nKyHi9iVers This is the way..
@WatchingTokyo
@WatchingTokyo 8 күн бұрын
Thanks a lot for this series. I have a question: after line 22 and before running the task, ideally shouldn't you call "condition.notify_one();"? With the code as it is in the video it seems that the other thread's "condition.wait" will run spuriously instead of being notified. Thanks!
@mdtarikbosunia2435
@mdtarikbosunia2435 10 ай бұрын
I love your every video. thanks for making videos
@chnsnyz
@chnsnyz 5 ай бұрын
I admire you for sharing this content with us. I have some question marks regarding the use of locks and std::function Thanks a lot. 1 - Why you acquired the mutex in the desctructor? I could not see the point since no thread is modifying the stop flag. Tried 8 threads and 1,6 milion of tasks, worked perfectly fine without the mutex acquisition. 2 - Also didnot see the point to use unlock() in the enqueue() function. Removed it. Still works totally fine. 3 - In the enqueue() function, I did not get the idea of using template. Since the type of the workers is std::queue, it cannot get other signatured invokable objects than void(), no? I tried to pass a lambda with the signature of void(int), it failed. So what is the point of the template?
@sudarshan_adiga_k
@sudarshan_adiga_k 10 ай бұрын
Can you please make few videos on how to communicate with DB like Oracle SQL in cpp?
@CppNuts
@CppNuts 10 ай бұрын
This will take time maybe..
@saravanavijayan1
@saravanavijayan1 6 ай бұрын
Good explanation and highly appreaciated.
@CppNuts
@CppNuts 4 ай бұрын
Glad it was helpful!
@RomilAggarwal611
@RomilAggarwal611 9 ай бұрын
Thanks, nice video! During this video I got stuck in an endless loop while learning about capture clauses in lamdas, std::function, move, forward, default, delete and probably a couple more while watching this video 😅 I had too many gaps. actually, I landed in this playlist cuz I got stuck in one such loops and my stack has now definitely overflowed and I don't even remember what I was studying in the first place... I was studying caching but I don't even remember how I ended up here.
@CppNuts
@CppNuts 4 ай бұрын
So did you finally understood ?
@RomilAggarwal611
@RomilAggarwal611 4 ай бұрын
@@CppNuts had taken a while to go through everything but yes!
@mohanrajanna9026
@mohanrajanna9026 8 ай бұрын
excellent video. very clear
@janardhanreddy1180
@janardhanreddy1180 10 ай бұрын
Finally we saw you 😊
@DiegoCapoccitti
@DiegoCapoccitti 10 ай бұрын
Thank you for this video, it's very interesting! I have a question: is there a way to know when all the threads have completed their work so that the main thread can wait? Thank you.
@CppNuts
@CppNuts 10 ай бұрын
The current code will wait for all the work to finish then only it will terminate. Because termination is written in Destructor it will start the destroying when return 0; is hit. But in thread if you see there is a check (stop && tasks.empty ()) this will not allow to return from thread if tasks queue is not empty. I will paste the current code link you can run and check it will br very helpful.
@DiegoCapoccitti
@DiegoCapoccitti 10 ай бұрын
@@CppNuts Thank you!
@nitin_puranik
@nitin_puranik 10 ай бұрын
Why does every KZbin thumbnail now have the host with either their mouth open in the O-shape or a finger on their lips? Does the KZbin algorithm give an extra push to such videos now? Humanity now seems to be on an intellectual race to the bottom! No complaints about the content of this video. Great one, thanks brother!
@CppNuts
@CppNuts 10 ай бұрын
I thought let's just do what others are doing may be they are doing for some reason 😬 I never did the research.. 🙃 Thanks for putting thoughts on this, I also feel the same way now.
@ayushjindal4981
@ayushjindal4981 4 ай бұрын
when will the inner infinite loop end? and when will the next threads get created? I am not able to understand.
@CppNuts
@CppNuts 4 ай бұрын
The inner loop will never end till the program is running. Pools are like we keep them running for any incoming jobs, and jobs can come anytime hence we have to keep on waiting state for the job. Please read about conditional variable then you will know what is happening.
@kirandhegaskar9298
@kirandhegaskar9298 9 ай бұрын
Why vector worker has not type of function, as we are pushing lambda function to it
@Account-fi1cu
@Account-fi1cu 5 ай бұрын
the workers vector is of type thread, it pushes new threads with dedicated function. std::thread accepts function as its 1st argument. so when we emplace_back a new thread object, we implicitly declare a new thread object, and give a lambda function as its 1st argument to the new thread inside vector.
@bhushanrane7459
@bhushanrane7459 10 ай бұрын
Thank Bro ❤
@GameDevGeeks
@GameDevGeeks 2 ай бұрын
awesome, now I'm gonna build my own game engine LOL
@RAMANKUMAR-xl4pr
@RAMANKUMAR-xl4pr 6 ай бұрын
Thanks for the nice content, where is the source code for the same video. Can you share it, what is the process to get the code for videos? Thanks
@CppNuts
@CppNuts 5 ай бұрын
Plz check channel about page. You will get the link of git hub
@purushothamanv.a.1090
@purushothamanv.a.1090 10 ай бұрын
Please Explain MFC
@krishnanarwani8105
@krishnanarwani8105 4 ай бұрын
You make things complex unnecessarily. I see many places where things could have been easily simplified for beginners.
@CppNuts
@CppNuts 4 ай бұрын
I am sorry for making you feel that way. But Thread Pool is little complex which require many basic concepts should be clear. (mutex and condition_variable, function pointer etc..)
Object Pool With Multithreading In C++ | Part 2
8:02
CppNuts
Рет қаралды 3,8 М.
How to write Thread Pools in C++
13:37
Zen Sepiol
Рет қаралды 10 М.
#behindthescenes @CrissaJackson
0:11
Happy Kelli
Рет қаралды 27 МЛН
Hilarious FAKE TONGUE Prank by WEDNESDAY😏🖤
0:39
La La Life Shorts
Рет қаралды 44 МЛН
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 908 М.
Thread Pools in Java
18:04
Jakob Jenkov
Рет қаралды 72 М.
Zig For the Uninitiated: Zig Interfaces
11:56
Tyler Calder
Рет қаралды 2,3 М.
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 850 М.
Thread Pools in C (using the PTHREAD API)
22:54
CodeVault
Рет қаралды 45 М.
How to write a Concurrent Thread-safe Queue from scratch?
17:14
Arpit Bhayani
Рет қаралды 14 М.
Parallelizing the Naughty Dog Engine Using Fibers
1:06:02
Vadim Chuprakov
Рет қаралды 7 М.
Weak Pointers in C++ (std::weak_ptr)
17:25
The Cherno
Рет қаралды 61 М.
Mutex VS Semaphore In C++
7:17
CppNuts
Рет қаралды 24 М.
#behindthescenes @CrissaJackson
0:11
Happy Kelli
Рет қаралды 27 МЛН