• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Swift and Threads
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Swift and Threads


  • Subject: Re: Swift and Threads
  • From: Quincey Morris <email@hidden>
  • Date: Mon, 12 Sep 2016 11:11:53 -0700
  • Feedback-id: 167118m:167118agrif8a:167118sE7JjjSVJy:SMTPCORP

On Sep 12, 2016, at 10:16 , Jens Alfke <email@hidden> wrote:
>
> The question in my mind is whether the array struct ever gets copied in this code — it’s not explicitly passed as a parameter, just closed over. I don’t think I’ve read any docs that describe explicitly what the behavior is, maybe because it only becomes significant when you introduce threads?

The array is going to get copied at least once, because it’s a local variable captured by a block. That means it needs to be copied to the heap.

> This situation also begs the question of what kind of lower-level data structure one can use in Swift when Array is too high-level. In Obj-C one can drop down to C arrays, for example.

My understanding is that pure Swift arrays (that is, *not* bridged NSArrays) are stored as efficiently as C arrays.

However, in this particular example, the array, a mutable structure, is modified unsafely from multiple threads. That may or may not be the cause of the crash, but it’s certainly a bug that should be fixed first.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Swift and Threads
      • From: Jens Alfke <email@hidden>
References: 
 >Swift and Threads (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: Swift and Threads (From: Jens Alfke <email@hidden>)
 >Re: Swift and Threads (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: How to do isKindOfClass in Swift
  • Next by Date: Re: Swift and Threads
  • Previous by thread: Re: Swift and Threads
  • Next by thread: Re: Swift and Threads
  • Index(es):
    • Date
    • Thread