{"action":"created","comment":{"url":"https://api.github.com/repos/servo/tendril/pulls/comments/44576785","id":44576785,"diff_hunk":"@@ -85,30 +179,40 @@ pub enum SubtendrilError {\n /// with one of the marker types from `tendril::fmt`. See the `StrTendril`\n /// and `ByteTendril` type aliases for two examples.\n ///\n+/// The type parameter `A` indicates the atomicity of the tendril; it is by\n+/// default `NonAtomic`, but can be specified as `Atomic` to get a tendril\n+/// which implements `Send` and `Sync` (viz. a thread-safe tendril).\n+///\n /// The maximum length of a `Tendril` is 4 GB. The library will panic if\n /// you attempt to go over the limit.\n #[cfg_attr(feature = \"unstable\", unsafe_no_drop_flag)]\n #[repr(packed)]\n-pub struct Tendril<F>\n+pub struct Tendril<F, A = NonAtomic>\n     where F: fmt::Format,\n+          A: Atomicity,\n {\n     ptr: Cell<NonZero<usize>>,\n     len: u32,\n     aux: Cell<u32>,\n     marker: PhantomData<*mut F>,\n+    refcount_marker: PhantomData<A>,\n }\n \n+unsafe impl<F, A> Send for Tendril<F, A> where F: fmt::Format, A: Atomicity + Sync { }\n+unsafe impl<F, A> Sync for Tendril<F, A> where F: fmt::Format, A: Atomicity + Sync { }","path":"src/tendril.rs","position":149,"original_position":149,"commit_id":"6f237186de9aeaa632fce08b66876836b15da6aa","original_commit_id":"6f237186de9aeaa632fce08b66876836b15da6aa","user":{"login":"SimonSapin","id":291359,"avatar_url":"https://avatars.githubusercontent.com/u/291359?v=3","gravatar_id":"","url":"https://api.github.com/users/SimonSapin","html_url":"https://github.com/SimonSapin","followers_url":"https://api.github.com/users/SimonSapin/followers","following_url":"https://api.github.com/users/SimonSapin/following{/other_user}","gists_url":"https://api.github.com/users/SimonSapin/gists{/gist_id}","starred_url":"https://api.github.com/users/SimonSapin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SimonSapin/subscriptions","organizations_url":"https://api.github.com/users/SimonSapin/orgs","repos_url":"https://api.github.com/users/SimonSapin/repos","events_url":"https://api.github.com/users/SimonSapin/events{/privacy}","received_events_url":"https://api.github.com/users/SimonSapin/received_events","type":"User","site_admin":false},"body":"@chris-morgan Reading this again, I think the `Send` impl here is safe but I’m not convinced about the `Sync` one, since `Tendril` contains `Cell`s. Can you explain the reasoning of why this is safe?","created_at":"2015-11-11T19:45:24Z","updated_at":"2015-11-11T19:45:24Z","html_url":"https://github.com/servo/tendril/pull/17#discussion_r44576785","pull_request_url":"https://api.github.com/repos/servo/tendril/pulls/17","_links":{"self":{"href":"https://api.github.com/repos/servo/tendril/pulls/comments/44576785"},"html":{"href":"https://github.com/servo/tendril/pull/17#discussion_r44576785"},"pull_request":{"href":"https://api.github.com/repos/servo/tendril/pulls/17"}}},"pull_request":{"url":"https://api.github.com/repos/servo/tendril/pulls/17","id":41094380,"html_url":"https://github.com/servo/tendril/pull/17","diff_url":"https://github.com/servo/tendril/pull/17.diff","patch_url":"https://github.com/servo/tendril/pull/17.patch","issue_url":"https://api.github.com/repos/servo/tendril/issues/17","number":17,"state":"closed","locked":false,"title":"Tendril types for Send and concurrency.","user":{"login":"chris-morgan","id":392868,"avatar_url":"https://avatars.githubusercontent.com/u/392868?v=3","gravatar_id":"","url":"https://api.github.com/users/chris-morgan","html_url":"https://github.com/chris-morgan","followers_url":"https://api.github.com/users/chris-morgan/followers","following_url":"https://api.github.com/users/chris-morgan/following{/other_user}","gists_url":"https://api.github.com/users/chris-morgan/gists{/gist_id}","starred_url":"https://api.github.com/users/chris-morgan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chris-morgan/subscriptions","organizations_url":"https://api.github.com/users/chris-morgan/orgs","repos_url":"https://api.github.com/users/chris-morgan/repos","events_url":"https://api.github.com/users/chris-morgan/events{/privacy}","received_events_url":"https://api.github.com/users/chris-morgan/received_events","type":"User","site_admin":false},"body":"This satisfies two of the items in “plans for the future” from the README. By setting `NonAtomic` as the default for the new type parameter, backwards compatibility (and convenience) is mostly maintained as `Tendril<F>` will still be non-atomic; `Tendril<F, Atomic>` opts in to the concurrency features.\n\nThe design and implementation of `Atomic` has not been vetted and should definitely not be merged without such vetting, because I’m not [this tall](http://bholley.net/images/posts/thistall.jpg).\n\n<!-- Reviewable:start -->\n[<img src=\"https://reviewable.io/review_button.png\" height=40 alt=\"Review on Reviewable\"/>](https://reviewable.io/reviews/servo/tendril/17)\n<!-- Reviewable:end -->\n","created_at":"2015-07-29T07:30:00Z","updated_at":"2015-11-11T19:45:24Z","closed_at":"2015-08-07T06:32:28Z","merged_at":"2015-08-07T06:32:28Z","merge_commit_sha":"a7c0131677c9303b2423b1305c9323b3f210aadf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/servo/tendril/pulls/17/commits","review_comments_url":"https://api.github.com/repos/servo/tendril/pulls/17/comments","review_comment_url":"https://api.github.com/repos/servo/tendril/pulls/comments{/number}","comments_url":"https://api.github.com/repos/servo/tendril/issues/17/comments","statuses_url":"https://api.github.com/repos/servo/tendril/statuses/6f237186de9aeaa632fce08b66876836b15da6aa","head":{"label":"chris-morgan:send-and-atomic","ref":"send-and-atomic","sha":"6f237186de9aeaa632fce08b66876836b15da6aa","user":{"login":"chris-morgan","id":392868,"avatar_url":"https://avatars.githubusercontent.com/u/392868?v=3","gravatar_id":"","url":"https://api.github.com/users/chris-morgan","html_url":"https://github.com/chris-morgan","followers_url":"https://api.github.com/users/chris-morgan/followers","following_url":"https://api.github.com/users/chris-morgan/following{/other_user}","gists_url":"https://api.github.com/users/chris-morgan/gists{/gist_id}","starred_url":"https://api.github.com/users/chris-morgan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chris-morgan/subscriptions","organizations_url":"https://api.github.com/users/chris-morgan/orgs","repos_url":"https://api.github.com/users/chris-morgan/repos","events_url":"https://api.github.com/users/chris-morgan/events{/privacy}","received_events_url":"https://api.github.com/users/chris-morgan/received_events","type":"User","site_admin":false},"repo":{"id":39300431,"name":"tendril","full_name":"chris-morgan/tendril","owner":{"login":"chris-morgan","id":392868,"avatar_url":"https://avatars.githubusercontent.com/u/392868?v=3","gravatar_id":"","url":"https://api.github.com/users/chris-morgan","html_url":"https://github.com/chris-morgan","followers_url":"https://api.github.com/users/chris-morgan/followers","following_url":"https://api.github.com/users/chris-morgan/following{/other_user}","gists_url":"https://api.github.com/users/chris-morgan/gists{/gist_id}","starred_url":"https://api.github.com/users/chris-morgan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chris-morgan/subscriptions","organizations_url":"https://api.github.com/users/chris-morgan/orgs","repos_url":"https://api.github.com/users/chris-morgan/repos","events_url":"https://api.github.com/users/chris-morgan/events{/privacy}","received_events_url":"https://api.github.com/users/chris-morgan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chris-morgan/tendril","description":"Compact string type for zero-copy parsing","fork":true,"url":"https://api.github.com/repos/chris-morgan/tendril","forks_url":"https://api.github.com/repos/chris-morgan/tendril/forks","keys_url":"https://api.github.com/repos/chris-morgan/tendril/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chris-morgan/tendril/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chris-morgan/tendril/teams","hooks_url":"https://api.github.com/repos/chris-morgan/tendril/hooks","issue_events_url":"https://api.github.com/repos/chris-morgan/tendril/issues/events{/number}","events_url":"https://api.github.com/repos/chris-morgan/tendril/events","assignees_url":"https://api.github.com/repos/chris-morgan/tendril/assignees{/user}","branches_url":"https://api.github.com/repos/chris-morgan/tendril/branches{/branch}","tags_url":"https://api.github.com/repos/chris-morgan/tendril/tags","blobs_url":"https://api.github.com/repos/chris-morgan/tendril/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chris-morgan/tendril/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chris-morgan/tendril/git/refs{/sha}","trees_url":"https://api.github.com/repos/chris-morgan/tendril/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chris-morgan/tendril/statuses/{sha}","languages_url":"https://api.github.com/repos/chris-morgan/tendril/languages","stargazers_url":"https://api.github.com/repos/chris-morgan/tendril/stargazers","contributors_url":"https://api.github.com/repos/chris-morgan/tendril/contributors","subscribers_url":"https://api.github.com/repos/chris-morgan/tendril/subscribers","subscription_url":"https://api.github.com/repos/chris-morgan/tendril/subscription","commits_url":"https://api.github.com/repos/chris-morgan/tendril/commits{/sha}","git_commits_url":"https://api.github.com/repos/chris-morgan/tendril/git/commits{/sha}","comments_url":"https://api.github.com/repos/chris-morgan/tendril/comments{/number}","issue_comment_url":"https://api.github.com/repos/chris-morgan/tendril/issues/comments{/number}","contents_url":"https://api.github.com/repos/chris-morgan/tendril/contents/{+path}","compare_url":"https://api.github.com/repos/chris-morgan/tendril/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chris-morgan/tendril/merges","archive_url":"https://api.github.com/repos/chris-morgan/tendril/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chris-morgan/tendril/downloads","issues_url":"https://api.github.com/repos/chris-morgan/tendril/issues{/number}","pulls_url":"https://api.github.com/repos/chris-morgan/tendril/pulls{/number}","milestones_url":"https://api.github.com/repos/chris-morgan/tendril/milestones{/number}","notifications_url":"https://api.github.com/repos/chris-morgan/tendril/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chris-morgan/tendril/labels{/name}","releases_url":"https://api.github.com/repos/chris-morgan/tendril/releases{/id}","created_at":"2015-07-18T14:15:07Z","updated_at":"2015-07-18T14:15:08Z","pushed_at":"2015-08-03T11:20:25Z","git_url":"git://github.com/chris-morgan/tendril.git","ssh_url":"git@github.com:chris-morgan/tendril.git","clone_url":"https://github.com/chris-morgan/tendril.git","svn_url":"https://github.com/chris-morgan/tendril","homepage":"","size":199,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"servo:master","ref":"master","sha":"060b16a4829a9d188fe3771aba96e1fdc7583605","user":{"login":"servo","id":2566135,"avatar_url":"https://avatars.githubusercontent.com/u/2566135?v=3","gravatar_id":"","url":"https://api.github.com/users/servo","html_url":"https://github.com/servo","followers_url":"https://api.github.com/users/servo/followers","following_url":"https://api.github.com/users/servo/following{/other_user}","gists_url":"https://api.github.com/users/servo/gists{/gist_id}","starred_url":"https://api.github.com/users/servo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/servo/subscriptions","organizations_url":"https://api.github.com/users/servo/orgs","repos_url":"https://api.github.com/users/servo/repos","events_url":"https://api.github.com/users/servo/events{/privacy}","received_events_url":"https://api.github.com/users/servo/received_events","type":"Organization","site_admin":false},"repo":{"id":32830295,"name":"tendril","full_name":"servo/tendril","owner":{"login":"servo","id":2566135,"avatar_url":"https://avatars.githubusercontent.com/u/2566135?v=3","gravatar_id":"","url":"https://api.github.com/users/servo","html_url":"https://github.com/servo","followers_url":"https://api.github.com/users/servo/followers","following_url":"https://api.github.com/users/servo/following{/other_user}","gists_url":"https://api.github.com/users/servo/gists{/gist_id}","starred_url":"https://api.github.com/users/servo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/servo/subscriptions","organizations_url":"https://api.github.com/users/servo/orgs","repos_url":"https://api.github.com/users/servo/repos","events_url":"https://api.github.com/users/servo/events{/privacy}","received_events_url":"https://api.github.com/users/servo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/servo/tendril","description":"Compact string type for zero-copy parsing","fork":false,"url":"https://api.github.com/repos/servo/tendril","forks_url":"https://api.github.com/repos/servo/tendril/forks","keys_url":"https://api.github.com/repos/servo/tendril/keys{/key_id}","collaborators_url":"https://api.github.com/repos/servo/tendril/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/servo/tendril/teams","hooks_url":"https://api.github.com/repos/servo/tendril/hooks","issue_events_url":"https://api.github.com/repos/servo/tendril/issues/events{/number}","events_url":"https://api.github.com/repos/servo/tendril/events","assignees_url":"https://api.github.com/repos/servo/tendril/assignees{/user}","branches_url":"https://api.github.com/repos/servo/tendril/branches{/branch}","tags_url":"https://api.github.com/repos/servo/tendril/tags","blobs_url":"https://api.github.com/repos/servo/tendril/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/servo/tendril/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/servo/tendril/git/refs{/sha}","trees_url":"https://api.github.com/repos/servo/tendril/git/trees{/sha}","statuses_url":"https://api.github.com/repos/servo/tendril/statuses/{sha}","languages_url":"https://api.github.com/repos/servo/tendril/languages","stargazers_url":"https://api.github.com/repos/servo/tendril/stargazers","contributors_url":"https://api.github.com/repos/servo/tendril/contributors","subscribers_url":"https://api.github.com/repos/servo/tendril/subscribers","subscription_url":"https://api.github.com/repos/servo/tendril/subscription","commits_url":"https://api.github.com/repos/servo/tendril/commits{/sha}","git_commits_url":"https://api.github.com/repos/servo/tendril/git/commits{/sha}","comments_url":"https://api.github.com/repos/servo/tendril/comments{/number}","issue_comment_url":"https://api.github.com/repos/servo/tendril/issues/comments{/number}","contents_url":"https://api.github.com/repos/servo/tendril/contents/{+path}","compare_url":"https://api.github.com/repos/servo/tendril/compare/{base}...{head}","merges_url":"https://api.github.com/repos/servo/tendril/merges","archive_url":"https://api.github.com/repos/servo/tendril/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/servo/tendril/downloads","issues_url":"https://api.github.com/repos/servo/tendril/issues{/number}","pulls_url":"https://api.github.com/repos/servo/tendril/pulls{/number}","milestones_url":"https://api.github.com/repos/servo/tendril/milestones{/number}","notifications_url":"https://api.github.com/repos/servo/tendril/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/servo/tendril/labels{/name}","releases_url":"https://api.github.com/repos/servo/tendril/releases{/id}","created_at":"2015-03-24T23:07:19Z","updated_at":"2015-11-11T16:42:55Z","pushed_at":"2015-11-11T18:56:10Z","git_url":"git://github.com/servo/tendril.git","ssh_url":"git@github.com:servo/tendril.git","clone_url":"https://github.com/servo/tendril.git","svn_url":"https://github.com/servo/tendril","homepage":"","size":402,"stargazers_count":36,"watchers_count":36,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":10,"forks":7,"open_issues":10,"watchers":36,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/servo/tendril/pulls/17"},"html":{"href":"https://github.com/servo/tendril/pull/17"},"issue":{"href":"https://api.github.com/repos/servo/tendril/issues/17"},"comments":{"href":"https://api.github.com/repos/servo/tendril/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/servo/tendril/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/servo/tendril/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/servo/tendril/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/servo/tendril/statuses/6f237186de9aeaa632fce08b66876836b15da6aa"}}}}