GitHub PullRequestReviewCommentEvent at 2014-11-26 00:35:54
Repository: rust
Actor: alexcrichton
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/comments/20908691","id":20908691,"diff_hunk":"@@ -8,43 +8,49 @@\n // option. This file may not be copied, modified, or distributed\n // except according to those terms.\n \n-//! A simple native mutex implementation. Warning: this API is likely\n-//! to change soon.\n+use prelude::*;\n \n-#![allow(dead_code)]\n-\n-use core::prelude::*;\n-use alloc::boxed::Box;\n-use rustrt::mutex;\n-\n-pub const LOCKED: uint = 1 << 0;\n-pub const BLOCKED: uint = 1 << 1;\n+use cell::UnsafeCell;\n+use kinds::marker;\n+use sync::{poison, AsMutexGuard};\n+use sys_common::mutex as sys;\n \n /// A mutual exclusion primitive useful for protecting shared data\n ///\n /// This mutex will properly block tasks waiting for the lock to become","path":"src/libstd/sync/mutex.rs","position":23,"original_position":23,"commit_id":"77f9bbdb5469a890dddd0c93628a2d7bff4002dc","original_commit_id":"77f9bbdb5469a890dddd0c93628a2d7bff4002dc","user":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars.githubusercontent.com/u/64996?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"body":"It means I forgot to reword this documentation.","created_at":"2014-11-26T00:35:54Z","updated_at":"2014-11-26T00:35:54Z","html_url":"https://github.com/rust-lang/rust/pull/19274#discussion_r20908691","pull_request_url":"https://api.github.com/repos/rust-lang/rust/pulls/19274","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments/20908691"},"html":{"href":"https://github.com/rust-lang/rust/pull/19274#discussion_r20908691"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/19274"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/19274","id":24958457,"html_url":"https://github.com/rust-lang/rust/pull/19274","diff_url":"https://github.com/rust-lang/rust/pull/19274.diff","patch_url":"https://github.com/rust-lang/rust/pull/19274.patch","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/19274","number":19274,"state":"open","locked":false,"title":"std: Rewrite the `sync` module","user":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars.githubusercontent.com/u/64996?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"body":"This commit is a reimplementation of `std::sync` to be based on the\r\nsystem-provided primitives wherever possible. The previous implementation was\r\nfundamentally built on top of channels, and as part of the runtime reform it has\r\nbecome clear that this is not the level of abstraction that the standard level\r\nshould be providing. This rewrite aims to provide as thin of a shim as possible\r\non top of the system primitives in order to make them safe.\r\n\r\nThe overall interface of the `std::sync` module has in general not changed, but\r\nthere are a few important distinctions, highlighted below:\r\n\r\n* The condition variable type, `Condvar`, has been separated out of a `Mutex`.\r\n  A condition variable is now an entirely separate type. This separation\r\n  benefits users who only use one mutex, and provides a clearer distinction of\r\n  who's responsible for managing condition variables (the application).\r\n\r\n* All of `Condvar`, `Mutex`, and `RWLock` are now directly built on top of\r\n  system primitives rather than using a custom implementation. The `Once`,\r\n  `Barrier`, and `Semaphore` types are still built upon these abstractions of\r\n  the system primitives.\r\n\r\n* The `Condvar`, `Mutex`, and `RWLock` types all have a new static type and\r\n  constant initializer corresponding to them. These are provided primarily for C\r\n  FFI interoperation, but are often useful to otherwise simply have a global\r\n  lock. The types, however, will leak memory unless `destroy()` is called on\r\n  them, which is clearly documented.\r\n\r\n* The fundamental architecture of this design is to provide two separate layers.\r\n  The first layer is that exposed by `sys_common` which is a cross-platform\r\n  bare-metal abstraction of the system synchronization primitives. No attempt is\r\n  made at making this layer safe, and it is quite unsafe to use! It is currently\r\n  not exported as part of the API of the standard library, but the stabilization\r\n  of the `sys` module will ensure that these will be exposed in time. The\r\n  purpose of this layer is to provide the core cross-platform abstractions if\r\n  necessary to implementors.\r\n\r\n  The second layer is the layer provided by `std::sync` which is intended to be\r\n  the thinnest possible layer on top of `sys_common` which is entirely safe to\r\n  use. There are a few concerns which need to be addressed when making these\r\n  system primitives safe:\r\n\r\n    * Once used, the OS primitives can never be **moved**. This means that they\r\n      essentially need to have a stable address. The static primitives use\r\n      `&'static self` to enforce this, and the non-static primitives all use a\r\n      `Box` to provide this guarantee.\r\n\r\n    * Poisoning is leveraged to ensure that invalid data is not accessible from\r\n      other tasks after one has panicked.\r\n\r\n  In addition to these overall blanket safety limitations, each primitive has a\r\n  few restrictions of its own:\r\n\r\n    * Mutexes and rwlocks can only be unlocked from the same thread that they\r\n      were locked by. This is achieved through RAII lock guards which cannot be\r\n      sent across threads.\r\n\r\n    * Mutexes and rwlocks can only be unlocked if they were previously locked.\r\n      This is achieved by not exposing an unlocking method.\r\n\r\n    * A condition variable can only be waited on with a locked mutex. This is\r\n      achieved by requiring a `MutexGuard` in the `wait()` method.\r\n\r\n    * A condition variable cannot be used concurrently with more than one mutex.\r\n      This is guaranteed by dynamically binding a condition variable to\r\n      precisely one mutex for its entire lifecycle. This restriction may be able\r\n      to be relaxed in the future (a mutex is unbound when no threads are\r\n      waiting on the condvar), but for now it is sufficient to guarantee safety.\r\n\r\n* Condvars support timeouts for their blocking operations. The\r\n  implementation for these operations is provided by the system.\r\n\r\nDue to the modification of the `Condvar` API, removal of the `std::sync::mutex`\r\nAPI, and reimplementation, this is a breaking change. Most code should be fairly\r\neasy to port using the examples in the documentation of these primitives.\r\n\r\n[breaking-change]\r\n\r\nCloses #17094\r\nCloses #18003","created_at":"2014-11-24T19:49:54Z","updated_at":"2014-11-26T00:35:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a7ac04165a0c0b106908ff51aa1c16b2f8c4c4ba","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/rust/pulls/19274/commits","review_comments_url":"https://api.github.com/repos/rust-lang/rust/pulls/19274/comments","review_comment_url":"https://api.github.com/repos/rust-lang/rust/pulls/comments/{number}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/19274/comments","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/77f9bbdb5469a890dddd0c93628a2d7bff4002dc","head":{"label":"alexcrichton:rewrite-sync","ref":"rewrite-sync","sha":"77f9bbdb5469a890dddd0c93628a2d7bff4002dc","user":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars.githubusercontent.com/u/64996?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"repo":{"id":7385331,"name":"rust","full_name":"alexcrichton/rust","owner":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars.githubusercontent.com/u/64996?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alexcrichton/rust","description":"a safe, concurrent, practical language","fork":true,"url":"https://api.github.com/repos/alexcrichton/rust","forks_url":"https://api.github.com/repos/alexcrichton/rust/forks","keys_url":"https://api.github.com/repos/alexcrichton/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alexcrichton/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alexcrichton/rust/teams","hooks_url":"https://api.github.com/repos/alexcrichton/rust/hooks","issue_events_url":"https://api.github.com/repos/alexcrichton/rust/issues/events{/number}","events_url":"https://api.github.com/repos/alexcrichton/rust/events","assignees_url":"https://api.github.com/repos/alexcrichton/rust/assignees{/user}","branches_url":"https://api.github.com/repos/alexcrichton/rust/branches{/branch}","tags_url":"https://api.github.com/repos/alexcrichton/rust/tags","blobs_url":"https://api.github.com/repos/alexcrichton/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alexcrichton/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alexcrichton/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/alexcrichton/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alexcrichton/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/alexcrichton/rust/languages","stargazers_url":"https://api.github.com/repos/alexcrichton/rust/stargazers","contributors_url":"https://api.github.com/repos/alexcrichton/rust/contributors","subscribers_url":"https://api.github.com/repos/alexcrichton/rust/subscribers","subscription_url":"https://api.github.com/repos/alexcrichton/rust/subscription","commits_url":"https://api.github.com/repos/alexcrichton/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/alexcrichton/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/alexcrichton/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/alexcrichton/rust/issues/comments/{number}","contents_url":"https://api.github.com/repos/alexcrichton/rust/contents/{+path}","compare_url":"https://api.github.com/repos/alexcrichton/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alexcrichton/rust/merges","archive_url":"https://api.github.com/repos/alexcrichton/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alexcrichton/rust/downloads","issues_url":"https://api.github.com/repos/alexcrichton/rust/issues{/number}","pulls_url":"https://api.github.com/repos/alexcrichton/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/alexcrichton/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/alexcrichton/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alexcrichton/rust/labels{/name}","releases_url":"https://api.github.com/repos/alexcrichton/rust/releases{/id}","created_at":"2012-12-31T08:59:51Z","updated_at":"2014-06-25T06:11:19Z","pushed_at":"2014-11-25T23:36:06Z","git_url":"git://github.com/alexcrichton/rust.git","ssh_url":"git@github.com:alexcrichton/rust.git","clone_url":"https://github.com/alexcrichton/rust.git","svn_url":"https://github.com/alexcrichton/rust","homepage":"http://www.rust-lang.org","size":230100,"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":"incoming"}},"base":{"label":"rust-lang:master","ref":"master","sha":"689ef2dabfa3b2b379c953e5fb68ce2c805c2231","user":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars.githubusercontent.com/u/5430905?v=3","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":724712,"name":"rust","full_name":"rust-lang/rust","owner":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars.githubusercontent.com/u/5430905?v=3","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rust-lang/rust","description":"a safe, concurrent, practical language","fork":false,"url":"https://api.github.com/repos/rust-lang/rust","forks_url":"https://api.github.com/repos/rust-lang/rust/forks","keys_url":"https://api.github.com/repos/rust-lang/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rust-lang/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rust-lang/rust/teams","hooks_url":"https://api.github.com/repos/rust-lang/rust/hooks","issue_events_url":"https://api.github.com/repos/rust-lang/rust/issues/events{/number}","events_url":"https://api.github.com/repos/rust-lang/rust/events","assignees_url":"https://api.github.com/repos/rust-lang/rust/assignees{/user}","branches_url":"https://api.github.com/repos/rust-lang/rust/branches{/branch}","tags_url":"https://api.github.com/repos/rust-lang/rust/tags","blobs_url":"https://api.github.com/repos/rust-lang/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rust-lang/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rust-lang/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/rust-lang/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/rust-lang/rust/languages","stargazers_url":"https://api.github.com/repos/rust-lang/rust/stargazers","contributors_url":"https://api.github.com/repos/rust-lang/rust/contributors","subscribers_url":"https://api.github.com/repos/rust-lang/rust/subscribers","subscription_url":"https://api.github.com/repos/rust-lang/rust/subscription","commits_url":"https://api.github.com/repos/rust-lang/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/rust-lang/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/rust-lang/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/rust-lang/rust/issues/comments/{number}","contents_url":"https://api.github.com/repos/rust-lang/rust/contents/{+path}","compare_url":"https://api.github.com/repos/rust-lang/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rust-lang/rust/merges","archive_url":"https://api.github.com/repos/rust-lang/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rust-lang/rust/downloads","issues_url":"https://api.github.com/repos/rust-lang/rust/issues{/number}","pulls_url":"https://api.github.com/repos/rust-lang/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/rust-lang/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/rust-lang/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rust-lang/rust/labels{/name}","releases_url":"https://api.github.com/repos/rust-lang/rust/releases{/id}","created_at":"2010-06-16T20:39:03Z","updated_at":"2014-11-26T00:23:23Z","pushed_at":"2014-11-25T22:36:59Z","git_url":"git://github.com/rust-lang/rust.git","ssh_url":"git@github.com:rust-lang/rust.git","clone_url":"https://github.com/rust-lang/rust.git","svn_url":"https://github.com/rust-lang/rust","homepage":"http://www.rust-lang.org","size":536714,"stargazers_count":7544,"watchers_count":7544,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1466,"mirror_url":null,"open_issues_count":2185,"forks":1466,"open_issues":2185,"watchers":7544,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/19274"},"html":{"href":"https://github.com/rust-lang/rust/pull/19274"},"issue":{"href":"https://api.github.com/repos/rust-lang/rust/issues/19274"},"comments":{"href":"https://api.github.com/repos/rust-lang/rust/issues/19274/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/19274/comments"},"review_comment":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/19274/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/rust/statuses/77f9bbdb5469a890dddd0c93628a2d7bff4002dc"}}}}