What is the Sendable protocol in Swift? | Swift Concurrency #11

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

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

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

    bro you are amazing
    Edit: Also sendable acts as a guard for future safery thread checks, is someone ads a var to a sendable without being aware its being used in asyc sendable will alert them.

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

    Amazing tutorial.Crystal clear.

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

    8:41 - In xCode 14.1 there will only be a warning and not an error.

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

      Update: I think in Swift 6 it will become an error, for now just a warning

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

    Awesommmmmme Video! Thank you so much fore great video! A huge Salute to you 999999999999 times! Keep sharing your knowledge & making awesome video! genius!

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

    Thank you as always for your great work Nick!

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

    Awesome as always. Thank you so much!!!

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

    Great video, thanks!

  • @liumingxing3060
    @liumingxing3060 5 หลายเดือนก่อน

    Cool!

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

    Your videos are great, do you have a plan to cover Transferable

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

    Trying to think of a case that a final class would be needed where a struct or actor couldn’t fit the bill. In the unchecked sendable case shown in the video all we are really doing making an understudy, weak actor, aka an novice implementation of thread safe class? What am I missing?

  • @lalitvinde1441
    @lalitvinde1441 9 หลายเดือนก่อน

    hey vro ...how to make Core Data Entities conforming to Sendable??

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

    What is the brand of your keyboard that sound is very impress me

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

      That is a 16” MacBook Pro 😂

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

      @@SwiftfulThinking omg 😱

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

    as i said before about mutating.. you must be careful.
    struct MyStruct: Sendable {
    var title: String
    mutating func changeTitle(newTitle: String) {
    title = newTitle
    }
    func unsafe( t: inout MyStruct) {
    t.changeTitle(newTitle: "new title")
    }
    func test() {
    var t = MyStruct(title: "hello")
    unsafe(t: &t)
    print(t.title)
    }
    }

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

      This obviously isn't thread-safe.

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

      @@alexvaiman4966yea I guess I should have been more clear about immutable structs vs mutable structs too

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

      @@SwiftfulThinking Actually, I was wrong. When you try to run a mutating struct function in a thread context, you will get an error saying 'Escaping closure captures mutating 'self' parameter.' So, I guess it is not that structs are thread-safe; they just cannot be shared between threads (which is logical, as most structs are created on the stack). Swift is smart, unlike C++, it will not let you do crazy things.