So amazing, I don't understand my teacher's multi-threading classes for two weeks.And i know the meaning of time mutex from your video. Thanks very much !!!!!
Hi I didn't get the diff b/w "try_lock_for" and "try_lock_until". In both the cases we are waiting for specified time limit then what is the exact diff b/w both types ?
try_lock_for - to simply say, blocks for 'n' seconds try_lock_until - blocks till given time - say current time is 9:14 am(time::now) & time::now + 1 = 9:14 + 1sec extra.
I didn't get the diff b/w "try_lock_for" and "try_lock_until". In both the cases we are waiting for specified time limit then what is the exact diff b/w both types ?
In the first, you give it time to wait for, in the second you give it the particular moment in time in which it will stop waiting for the lock to be free. I.e., in the first, you give relative time, while in the second you give absolute time. We use chrono library to give that particular moment in time, which chrono probably (almost certainly) translates to UNIX time.
@@cid007007I found this but haven't tried yet: sourceforge.net/p/tdm-gcc/bugs/211/ Someone suggested adding -std=gnu++11 to a command line. I don't know how to compile in codeblock using command line. If you succesfully compiled and ran the code with this solution, please let me know. I'll try it too.
@@jumbo999614 Thanks Paul for reply.. But I have already checked "-std=c++14" as compiler flags in Settings --> Compiler --> Compiler flags in Code blocks and Selected Compiler is "GNU GCC Compiler"... but no luck :(
But that's what is happening no?? And by the way thanks for pasting the code here, generally people just ask the question without giving the code and it is very hard to understand their problem.
So amazing, I don't understand my teacher's multi-threading classes for two weeks.And i know the meaning of time mutex from your video. Thanks very much !!!!!
Glad it was helpful!
This is such a great series. Thank you!
Thanks man!!
bohut mast aadmi ho aap !
thanks for all the videos
Thank you so much for the in detail explanation.
Thankyou so much .nice explanation
Thanks for the comment dude!!
Hi
I didn't get the diff b/w "try_lock_for" and "try_lock_until". In both the cases we are waiting for specified time limit then what is the exact diff b/w both types ?
try_lock_for - to simply say, blocks for 'n' seconds
try_lock_until - blocks till given time - say current time is 9:14 am(time::now) & time::now + 1 = 9:14 + 1sec extra.
Love your videos
Thanks man!!
I didn't get the diff b/w "try_lock_for" and "try_lock_until". In both the cases we are waiting for specified time limit then what is the exact diff b/w both types ?
In the first, you give it time to wait for, in the second you give it the particular moment in time in which it will stop waiting for the lock to be free. I.e., in the first, you give relative time, while in the second you give absolute time. We use chrono library to give that particular moment in time, which chrono probably (almost certainly) translates to UNIX time.
Great video Thanks Rupesh
My pleasure..
An awesome explanation thanks man.
Glad it was helpful!
this guy is best.
Thanks dude..
Another great video.. thanks a lot
Thanks man!!
youre the best bro
Thanks bro .
Nicely explained .... Thank you :)
Glad it was helpful!
one word - fantastic .!
Thanks..
could you please share the code link in description only?
it will help a lot.
thank you
Dude, i have kept code distribution to members only.
You can be a member and its cheap like not even a meal price.
Timed Mutex is member function of Mutex, or it is another class like normal mutex?
It is a different class, like we have mutex as different class.
I got error from std::timed_mutex. it said "timed_mutex in namespace 'std' does not name a type".
same... i am using codeblocks editor.. any resolution u got fr this ?
@@cid007007I found this but haven't tried yet: sourceforge.net/p/tdm-gcc/bugs/211/ Someone suggested adding -std=gnu++11 to a command line.
I don't know how to compile in codeblock using command line. If you succesfully compiled and ran the code with this solution, please let me know. I'll try it too.
@@jumbo999614 Thanks Paul for reply.. But I have already checked "-std=c++14" as compiler flags in Settings --> Compiler --> Compiler flags in Code blocks and Selected Compiler is "GNU GCC Compiler"... but no luck :(
I also tried std=c++11. Didn't work either.
Maybe we should download the same compiler the author of this video uses.
@@jumbo999614 It worked with latest version of Code::Blocks 20.03.. I installed that and run timed_mutex compiling and running... :)
good music und explaination
Thanks
required some simple explanation??
It is there plz revisit.
why i am getting ouput
Executed thread num: 1 sum: 1
Executed thread num: 1 sum: 2
Executed thread num: 1 sum: 3
Executed thread num: 1 sum: 4
Executed thread num: 1 sum: 5
Executed thread num: 2 sum: 6
Executed thread num: 2 sum: 7
Executed thread num: 2 sum: 8
Executed thread num: 2 sum: 9
Executed thread num: 2 sum: 10
Thread 1Exit
Thread 2Exit
for following code:
// Online C++ compiler to run C++ program online
#include
#include
#include
#include
using namespace std;
int sum =0;
timed_mutex m;
int print_f(int thread_num, int count)
{
m.try_lock_for(chrono::seconds(2));
for(int i=0; i
But that's what is happening no??
And by the way thanks for pasting the code here, generally people just ask the question without giving the code and it is very hard to understand their problem.