Lock Guard In C++

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

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

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

    You're genuinely sincere in teaching a concept. Loving all your hands on tutorials ... God Bless You ❤

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

    The best cpp channel on TH-cam. Thank you so much

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

      Thanks man..

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

    I was using ACE library for multithreading in c++. Totally unaware about how to use concept with direct c++ libraries and developed laziness due to fear of new syntaxes . After going through your playlist felt like nirvana :) . You are doing awesome work. Keep doing. Keep enlighten people.

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

      Thanks..

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

    You have a talent to explain things easily, man. Great job! Thank you

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

      Thanks man..

  • @shivaprasad8142
    @shivaprasad8142 4 ปีที่แล้ว +8

    Hi Rupesh, Your concept explanation is good, but the only thing I feel missing in the videos is that real-time example of the concept and its advantages over traditional concepts if that gets added up it would really help the viewers to understand the concept better
    like for example :
    "when returning, or when an exception is thrown. You should always prefer to use lock_guard or unique_lock instead of using mutex:: lock()"
    Example:
    ================== Traditional Lock Problem =================
    std:: mutex m1; // Mutex Declaration
    some Func( ) {
    try
    {
    m1.lock(); // Lock Aquired
    Tcp/Udp request call(); or // If any of these call fails then "lock remains"
    SomeDllCall() or
    ThirdPartyLibraryCall()
    m1.Unlock(); // Lock Released
    }
    catch(Exception Handler e)
    Cout

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

      Great dude, thanks for the comment and code.

    • @xinking2644
      @xinking2644 2 ปีที่แล้ว

      thank you for the code :)

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

    The real power of lock_guard as you mentioned in the comments is in RAII. I was asked RAII in an interview but I did not know :(. I guess this deserves a seperate video like you awesome video on RVO and NRVO.

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

      Will try, now i am so much busy these day!!

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

      RAII - Resource Acquisition Is Initialization!

  • @ryandsouza9093
    @ryandsouza9093 4 ปีที่แล้ว +2

    Your videos are awesome! You should seriously write a book.

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

      Thanks

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

    Thank you!!

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

      You are welcome..

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

    as you told in previous video that you are going to upload vlogs for program but i am not able to get the link .please share the link in description .

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

    great work rupesh

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

      Thanks!!

  • @matheusribeiro2739
    @matheusribeiro2739 2 ปีที่แล้ว

    awesome!

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

    Good job!

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

      I tried

  • @edwin3928ohd
    @edwin3928ohd 2 ปีที่แล้ว

    Thanks!!

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

      Glad you liked it..

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

    I am here to know when to use lock_gurad vs unique lock partially i got answer will see next video on unique lock thank you ::)

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

      Great 👍

  • @vaibhavgupta8048
    @vaibhavgupta8048 5 ปีที่แล้ว +2

    what if any exception occurs in the for loop , how lock_guard will be advantageous ..

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

      It will release lock while stack unwinding.

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

    you rock~!

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

      Thanks..

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

    how can we make sure thread T0 always execute first ??

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

      Using condition variable, i have video for that plz go for it.

  • @kevin-ru6oe
    @kevin-ru6oe 4 ปีที่แล้ว

    Are your videos based on a book? I would like to know the name of that book. Or if you can recommend me a book to learn about concurrency problems, threads and mutual exclusion, I would thank you.

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

      No my videos are not from any book, they are from my heart. ❤️
      And I have never read any book for c plus plus.
      Thanks man..

    • @kevin-ru6oe
      @kevin-ru6oe 4 ปีที่แล้ว

      @@CppNuts Thanks for your answer

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

    How to read first 5lines with a thread and next 5lines with second thread... and again use the first thread to read next 5lines

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

    Mutex Week

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

      Yes!! 😊