{"id":13741,"date":"2016-03-03T11:06:55","date_gmt":"2016-03-03T16:06:55","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=13741"},"modified":"2016-03-03T11:06:55","modified_gmt":"2016-03-03T16:06:55","slug":"proposed-new-swift-collections-model","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2016\/03\/03\/proposed-new-swift-collections-model\/","title":{"rendered":"Proposed New Swift Collections Model"},"content":{"rendered":"<p><a href=\"https:\/\/github.com\/gribozavr\/swift-evolution\/blob\/new-collections\/proposals\/NNNN-collections-move-indices.md\">Dmitri Gribenko<\/a> et. al.:<\/p>\n<blockquote cite=\"https:\/\/github.com\/gribozavr\/swift-evolution\/blob\/new-collections\/proposals\/NNNN-collections-move-indices.md\">\n<p>We are proposing a new model for collections, where indices can only be\nadvanced forward or backward by the corresponding collection instance.\nIndices become opaque tokens representing collection positions, that can\nbe produced and consumed by collection APIs.  This allows us to reduce\nthe amount of data stored in indices to the bare minimum.<\/p>\n<p>[&#8230;]<\/p>\n<p>Instances of <code>Dictionary<\/code> point to an indirection, while instances of\n<code>DictionaryIndex<\/code> point to the storage itself.  This allows us to have\ntwo separate reference counts.  One of the refcounts tracks just the\nlive <code>Dictionary<\/code> instances, which allows us to perform precise\nuniqueness checks.<\/p>\n<p>The issue that we were previously unaware of is that this scheme is not\nthread-safe.  When uniquely-referenced storage is being mutated in\nplace, indices can be concurrently being incremented (on a different\nthread).  This would be a read\/write data race.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Dmitri Gribenko et. al.: We are proposing a new model for collections, where indices can only be advanced forward or backward by the corresponding collection instance. Indices become opaque tokens representing collection positions, that can be produced and consumed by collection APIs. This allows us to reduce the amount of data stored in indices to [&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":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","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":[131,800,46,571,138,71,901],"class_list":["post-13741","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-bug","tag-concurrency","tag-languagedesign","tag-memory-management","tag-optimization","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/13741","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=13741"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/13741\/revisions"}],"predecessor-version":[{"id":13742,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/13741\/revisions\/13742"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=13741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=13741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=13741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}