Rust: Send Data between Threads

Sdílet
Vložit
  • čas přidán 12. 09. 2024
  • #rust #thread #data
    Threads or actors communicate with one another by sending messages containing data
    The Rust Standard Library provides an implentation of Channels.
    A Channel is concept where one thread sends data to another thread.
    Links
    The Rust Programming Book
    Chapter 16 Section 2
    doc.rust-lang....

Komentáře • 17

  • @LucidGR
    @LucidGR Před 7 měsíci

    This channel deserves a tone of subscribers. Great job!

  • @bissbort
    @bissbort Před rokem +1

    Love your teaching style and your channel, please keep up the good work. I hope your popularity will grow with Rust's 🦀!

  • @rsalmei
    @rsalmei Před 2 měsíci

    What font do you use? Very nice.

  • @Gabriel250100
    @Gabriel250100 Před rokem

    The next topic will be great, I'm coding an app which uses shared state and it's hard to work with library structs that aren't Send+Sync. Nice video as always

    • @user-uf4lf2bp8t
      @user-uf4lf2bp8t Před 24 dny

      Thats a bad library if their types use some !Send cell and they don't have a feature to make it into a mutex instead. Same thing if they use exclusively Rc with no Arc feature

  • @job4753
    @job4753 Před rokem

    Great video once again!

  • @736939
    @736939 Před rokem

    OK, but where to use it? Is there some design patterns in message passing?

  • @roopeshsaravanan8609
    @roopeshsaravanan8609 Před 8 měsíci

    Your 5000th subscriber ❤

  • @danraine9009
    @danraine9009 Před rokem

    Awesome video, if you were trying to utilise threads to the maximum level would you need to do some sort of logic to get the users specs of machine and how many threads their system is capable of etc? I honestly don't have any experience with threads or really much knowledge of the underlying processes of a CPU etc and if it does differentiate between machines etc... Is this knowledge needed? and if so do you have any places to look to learn more about these ideas?
    Thanks for the videos I've only recently found your channel but everything I have watched so far has been really valuable.

    • @TheDevMethod
      @TheDevMethod  Před rokem +1

      Improving execution performance can get really technical and expansive really fast. There’s even techniques like loop unrolling to help speed up the current process of execution rather than trying to use threads. This article could give you ideas of what to look into next blog.mineiros.io/how-to-use-multithreading-and-multiprocessing-a-beginners-guide-to-parallel-and-concurrent-a69b9dd21e9d

    • @danraine9009
      @danraine9009 Před rokem

      @@TheDevMethod Awesome response thank you, I am very new to this area so apologies if my question wasn't great I'm just trying to get as much information as possible. Keep up the great work :)

  • @marcel2023
    @marcel2023 Před rokem

    What happens if that thread you are sending messages to, is really busy. Will messages be dropped or will the sending wait. Is there some sort of acknowledge?

    • @TheDevMethod
      @TheDevMethod  Před rokem

      The docs explain that the send method returns a Result that can be a SendError doc.rust-lang.org/std/sync/mpsc/struct.Sender.html#method.send. And that error comes from the receiver that disconnected while sending. doc.rust-lang.org/std/sync/mpsc/struct.SendError.html.

    • @songz9781
      @songz9781 Před rokem

      I mostly work with async runtimes in Rust - which is usually within the “futures” crate. The mpsc channel has back pressure support and let you define either the channel should have certain size of a buffer or “unbounded” channel that put developer in charge of make sure the channel won’t be crowded. Hope this helps.

  • @adaum79
    @adaum79 Před rokem

    Nice vídeo

  • @nothingtoospecial777
    @nothingtoospecial777 Před rokem

    what's the theme?