Correct me if I'm wrong, but this is what I believe is happening: The short answer is that we don't need a mutex lock for Worker::set_count because set_count is not changing a shared variable. Worker::set_count is altering the worker's own variable and not the shared variable. The long answer: Imagine that each worker is a real person in a car and a mutex lock is traffic light. The shared variable is a target, past the traffic light, that needs to be hit. Now, each worker needs to know the address of the target, and so it has it's own notebook where it writes down this address. In this case, the notebook is the variable. Since each worker has it's own variable we don't need a mutex lock to protect it because we will never encounter a situation where another worker has access to another worker's notebook. But since there is only one target, we need a mutex lock so that only one worker, at a time, gets past the traffic light to hit the target .
Soon actually, I just want to cover some more basics but I don't want to get too deep because I already cover all the basics in my courses. I'm thinking about covering networking and maybe some library creation and then going gui
Nice 👍 thank you 🙏
Worker::run is locked by a mutex. But why Worker::set_count doesn't need a mutex to lock it?
Correct me if I'm wrong, but this is what I believe is happening: The short answer is that we don't need a mutex lock for Worker::set_count because set_count is not changing a shared variable. Worker::set_count is altering the worker's own variable and not the shared variable.
The long answer:
Imagine that each worker is a real person in a car and a mutex lock is traffic light. The shared variable is a target, past the traffic light, that needs to be hit. Now, each worker needs to know the address of the target, and so it has it's own notebook where it writes down this address. In this case, the notebook is the variable. Since each worker has it's own variable we don't need a mutex lock to protect it because we will never encounter a situation where another worker has access to another worker's notebook. But since there is only one target, we need a mutex lock so that only one worker, at a time, gets past the traffic light to hit the target .
Is this course as complete as the paid course on Udemy?
No the Udemy courses go into more detail and I make these UA-cam videos with a different code style so the material is not repetitive or redundant
@@VoidRealms I'm from Vietnam, courses for QT / QML in Vietnam are very few. Do you do QML with QT6 ?
when will you teach gui qt
Soon actually, I just want to cover some more basics but I don't want to get too deep because I already cover all the basics in my courses. I'm thinking about covering networking and maybe some library creation and then going gui
@@VoidRealms ok got i am just a 12 year old kid i have basic understanding of c++ and qt
😀😃✌🤘👌👍🥉🥉🥉