Re: Swift and Threads
Re: Swift and Threads
- Subject: Re: Swift and Threads
- From: Jens Alfke <email@hidden>
- Date: Mon, 12 Sep 2016 10:16:34 -0700
> On Sep 12, 2016, at 9:34 AM, Jean-Daniel <email@hidden> wrote:
>
> Array are value based in Swift and so use COW optimization, which mean that even if you don’t resize them, you may hit a race condition issue.
Yes, you’re right. 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?
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.
Gerriet, would you mind re-asking your initial question on swift-users? I’d love to hear what the Swift gurus say about it.
—Jens
_______________________________________________
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