{"id":32851,"date":"2021-06-14T16:34:23","date_gmt":"2021-06-14T20:34:23","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=32851"},"modified":"2021-06-14T16:34:23","modified_gmt":"2021-06-14T20:34:23","slug":"concurrency-in-swift-5-and-6-data-races","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2021\/06\/14\/concurrency-in-swift-5-and-6-data-races\/","title":{"rendered":"Concurrency in Swift 5 and 6: Data Races"},"content":{"rendered":"<p><a href=\"https:\/\/forums.swift.org\/t\/concurrency-in-swift-5-and-6\/49337\">Douglas Gregor<\/a>:<\/p>\n<blockquote cite=\"https:\/\/forums.swift.org\/t\/concurrency-in-swift-5-and-6\/49337\"><p>An explicit goal of the concurrency effort for Swift 6 is to make safe-by-default also extend to data races. The type system and language model work together, through features like actors, <code>Sendable<\/code>, and global actors, to eliminate data races.<\/p><p>However, there is a lot of Swift code out there that was developed without the Swift concurrency model. Some portion of that code is going to have to change to fit within the constraints of Swift&rsquo;s concurrency model, but it&rsquo;s not going to be rewritten in a month or even a year. We need to consider what it&rsquo;s going to look like to migrate the Swift ecosystem to Swift 6, and expect that this process will take years.<\/p><p>[&#8230;]<\/p><p>To enable the incremental rollout of Swift 6&rsquo;s safe-by-default for data races, we&rsquo;ll allow the use of concurrency features in Swift 5 with a &ldquo;relaxed&rdquo; enforcement model that allows incremental adoption[&#8230;]<\/p><\/blockquote>\n\n<p>See also: <a href=\"https:\/\/swiftbysundell.com\/podcast\/99\/\">Swift by Sundell<\/a>.<\/p>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2021\/03\/18\/swift-proposal-actors\/\">Swift Proposal: Actors<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2021\/02\/22\/swift-proposal-concurrentvalue-and-concurrent-closures\/\">Swift Proposal: ConcurrentValue and @concurrent Closures<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2020\/11\/03\/swift-concurrency-roadmap\/\">Swift Concurrency Roadmap<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2019\/02\/05\/swift-5-exclusivity-enforcement\/\">Swift 5 Exclusivity Enforcement<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Douglas Gregor: An explicit goal of the concurrency effort for Swift 6 is to make safe-by-default also extend to data races. The type system and language model work together, through features like actors, Sendable, and global actors, to eliminate data races.However, there is a lot of Swift code out there that was developed without the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2021-06-14T20:34:26Z","apple_news_api_id":"d00d18f6-b157-4142-b59f-295ed74a644f","apple_news_api_modified_at":"2021-06-14T20:34:26Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/A0A0Y9rFXQUK1nyle10pkTw","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[800,31,2078,46,30,2077,54,71,901],"class_list":["post-32851","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-concurrency","tag-ios","tag-ios-15","tag-languagedesign","tag-mac","tag-macos-12","tag-objective-c","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/32851","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=32851"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/32851\/revisions"}],"predecessor-version":[{"id":32852,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/32851\/revisions\/32852"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=32851"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=32851"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=32851"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}