Timed Mutex In C++

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ม.ค. 2025

ความคิดเห็น • 46

  • @xinoili7551
    @xinoili7551 3 ปีที่แล้ว +4

    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 !!!!!

    • @CppNuts
      @CppNuts  3 ปีที่แล้ว +1

      Glad it was helpful!

  • @estebanduran6908
    @estebanduran6908 4 ปีที่แล้ว +1

    This is such a great series. Thank you!

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      Thanks man!!

  • @coolguy69235
    @coolguy69235 ปีที่แล้ว

    bohut mast aadmi ho aap !
    thanks for all the videos

  • @Learning_vidioes
    @Learning_vidioes ปีที่แล้ว

    Thank you so much for the in detail explanation.

  • @rteja4918
    @rteja4918 5 ปีที่แล้ว +3

    Thankyou so much .nice explanation

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว

      Thanks for the comment dude!!

  • @srinu571
    @srinu571 4 ปีที่แล้ว +1

    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 ?

    • @TusharHaral
      @TusharHaral 4 ปีที่แล้ว

      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.

  • @JohnieBraaf
    @JohnieBraaf 5 ปีที่แล้ว +1

    Love your videos

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว

      Thanks man!!

  • @pandurugovind7728
    @pandurugovind7728 3 ปีที่แล้ว +1

    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 ?

    • @m0st4fabeder
      @m0st4fabeder 6 หลายเดือนก่อน

      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.

  • @SearchingPeaceInside
    @SearchingPeaceInside 4 ปีที่แล้ว +1

    Great video Thanks Rupesh

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      My pleasure..

  • @abelashenafi6291
    @abelashenafi6291 ปีที่แล้ว

    An awesome explanation thanks man.

    • @CppNuts
      @CppNuts  ปีที่แล้ว

      Glad it was helpful!

  • @HIteshKumar-vu9gs
    @HIteshKumar-vu9gs 3 ปีที่แล้ว

    this guy is best.

    • @CppNuts
      @CppNuts  3 ปีที่แล้ว

      Thanks dude..

  • @ergingokkaya8323
    @ergingokkaya8323 5 ปีที่แล้ว +1

    Another great video.. thanks a lot

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว

      Thanks man!!

  • @coltonpekar2675
    @coltonpekar2675 3 ปีที่แล้ว

    youre the best bro

    • @CppNuts
      @CppNuts  3 ปีที่แล้ว

      Thanks bro .

  • @rajeshloknath898
    @rajeshloknath898 3 ปีที่แล้ว

    Nicely explained .... Thank you :)

    • @CppNuts
      @CppNuts  3 ปีที่แล้ว

      Glad it was helpful!

  • @amitmeenaiitb
    @amitmeenaiitb 3 ปีที่แล้ว

    one word - fantastic .!

    • @CppNuts
      @CppNuts  3 ปีที่แล้ว

      Thanks..

  • @ajayjadhav900
    @ajayjadhav900 4 ปีที่แล้ว +1

    could you please share the code link in description only?
    it will help a lot.
    thank you

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      Dude, i have kept code distribution to members only.
      You can be a member and its cheap like not even a meal price.

  • @mdshamshalam8925
    @mdshamshalam8925 5 ปีที่แล้ว +1

    Timed Mutex is member function of Mutex, or it is another class like normal mutex?

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว

      It is a different class, like we have mutex as different class.

  • @jumbo999614
    @jumbo999614 5 ปีที่แล้ว

    I got error from std::timed_mutex. it said "timed_mutex in namespace 'std' does not name a type".

    • @cid007007
      @cid007007 4 ปีที่แล้ว

      same... i am using codeblocks editor.. any resolution u got fr this ?

    • @jumbo999614
      @jumbo999614 4 ปีที่แล้ว

      @@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.

    • @cid007007
      @cid007007 4 ปีที่แล้ว

      @@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 :(

    • @jumbo999614
      @jumbo999614 4 ปีที่แล้ว

      I also tried std=c++11. Didn't work either.
      Maybe we should download the same compiler the author of this video uses.

    • @cid007007
      @cid007007 4 ปีที่แล้ว

      @@jumbo999614 It worked with latest version of Code::Blocks 20.03.. I installed that and run timed_mutex compiling and running... :)

  • @alsastar112
    @alsastar112 4 ปีที่แล้ว +1

    good music und explaination

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      Thanks

  • @selvapriya4115
    @selvapriya4115 5 ปีที่แล้ว +1

    required some simple explanation??

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว

      It is there plz revisit.

  • @shristiprakash8026
    @shristiprakash8026 8 หลายเดือนก่อน

    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

    • @CppNuts
      @CppNuts  4 หลายเดือนก่อน

      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.