{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/comments/121577509","pull_request_review_id":43615213,"id":121577509,"diff_hunk":"@@ -787,12 +787,16 @@ pub fn park_timeout_ms(ms: u32) {\n ///\n /// let timeout = Duration::from_secs(2);\n /// let beginning_park = Instant::now();\n-/// park_timeout(timeout);\n ///\n-/// while beginning_park.elapsed() < timeout {\n-///     println!(\"restarting park_timeout after {:?}\", beginning_park.elapsed());\n-///     let timeout = timeout - beginning_park.elapsed();\n-///     park_timeout(timeout);\n+/// let mut timeout_remaining = timeout;\n+/// loop {\n+///     park_timeout(timeout_remaining);\n+///     let elapsed = beginning_park.elapsed();\n+///     if elapsed >= timeout {","path":"src/libstd/thread/mod.rs","position":14,"original_position":14,"commit_id":"0389d40ce0a891bc7d37ca15c12e23df79d71524","original_commit_id":"0389d40ce0a891bc7d37ca15c12e23df79d71524","user":{"login":"mark-buer","id":2610458,"avatar_url":"https://avatars0.githubusercontent.com/u/2610458?v=3","gravatar_id":"","url":"https://api.github.com/users/mark-buer","html_url":"https://github.com/mark-buer","followers_url":"https://api.github.com/users/mark-buer/followers","following_url":"https://api.github.com/users/mark-buer/following{/other_user}","gists_url":"https://api.github.com/users/mark-buer/gists{/gist_id}","starred_url":"https://api.github.com/users/mark-buer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mark-buer/subscriptions","organizations_url":"https://api.github.com/users/mark-buer/orgs","repos_url":"https://api.github.com/users/mark-buer/repos","events_url":"https://api.github.com/users/mark-buer/events{/privacy}","received_events_url":"https://api.github.com/users/mark-buer/received_events","type":"User","site_admin":false},"body":"Nah, I think it is right as-is.\r\n\r\nIn the loop, `elapsed` is the total duration since creation of `beginning_park` (created outside of the loop). It is a rough measure of the total duration we've parked for thus far.\r\n`timeout` is the total desired park duration.\r\nThus, comparing the two seems okay (we're comparing two \"totals\").\r\nIf we need to park some more, we calculate the difference between the total desired park duration and the total elapsed park duration, and use that value in yet-another-park.","created_at":"2017-06-13T03:56:12Z","updated_at":"2017-06-13T03:56:12Z","html_url":"https://github.com/rust-lang/rust/pull/42597#discussion_r121577509","pull_request_url":"https://api.github.com/repos/rust-lang/rust/pulls/42597","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments/121577509"},"html":{"href":"https://github.com/rust-lang/rust/pull/42597#discussion_r121577509"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/42597"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/42597","id":125059058,"html_url":"https://github.com/rust-lang/rust/pull/42597","diff_url":"https://github.com/rust-lang/rust/pull/42597.diff","patch_url":"https://github.com/rust-lang/rust/pull/42597.patch","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/42597","number":42597,"state":"open","locked":false,"title":"Capture elapsed duration in Thread::park_timeout example","user":{"login":"mark-buer","id":2610458,"avatar_url":"https://avatars0.githubusercontent.com/u/2610458?v=3","gravatar_id":"","url":"https://api.github.com/users/mark-buer","html_url":"https://github.com/mark-buer","followers_url":"https://api.github.com/users/mark-buer/followers","following_url":"https://api.github.com/users/mark-buer/following{/other_user}","gists_url":"https://api.github.com/users/mark-buer/gists{/gist_id}","starred_url":"https://api.github.com/users/mark-buer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mark-buer/subscriptions","organizations_url":"https://api.github.com/users/mark-buer/orgs","repos_url":"https://api.github.com/users/mark-buer/repos","events_url":"https://api.github.com/users/mark-buer/events{/privacy}","received_events_url":"https://api.github.com/users/mark-buer/received_events","type":"User","site_admin":false},"body":"`beginning_park.elapsed()` might return a larger value within the loop as compared to that checked in the loop conditional.\r\nSince `Duration` arithmetic is checked, hitting such an edge case will cause a panic.","created_at":"2017-06-12T04:21:33Z","updated_at":"2017-06-13T03:56:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5ff73e30ca0df47441c20da465e903d189974e86","assignee":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars2.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},"assignees":[{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars2.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}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/rust/pulls/42597/commits","review_comments_url":"https://api.github.com/repos/rust-lang/rust/pulls/42597/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/42597/comments","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/0389d40ce0a891bc7d37ca15c12e23df79d71524","head":{"label":"mark-buer:park_timeout_example_fix","ref":"park_timeout_example_fix","sha":"0389d40ce0a891bc7d37ca15c12e23df79d71524","user":{"login":"mark-buer","id":2610458,"avatar_url":"https://avatars0.githubusercontent.com/u/2610458?v=3","gravatar_id":"","url":"https://api.github.com/users/mark-buer","html_url":"https://github.com/mark-buer","followers_url":"https://api.github.com/users/mark-buer/followers","following_url":"https://api.github.com/users/mark-buer/following{/other_user}","gists_url":"https://api.github.com/users/mark-buer/gists{/gist_id}","starred_url":"https://api.github.com/users/mark-buer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mark-buer/subscriptions","organizations_url":"https://api.github.com/users/mark-buer/orgs","repos_url":"https://api.github.com/users/mark-buer/repos","events_url":"https://api.github.com/users/mark-buer/events{/privacy}","received_events_url":"https://api.github.com/users/mark-buer/received_events","type":"User","site_admin":false},"repo":{"id":39413478,"name":"rust","full_name":"mark-buer/rust","owner":{"login":"mark-buer","id":2610458,"avatar_url":"https://avatars0.githubusercontent.com/u/2610458?v=3","gravatar_id":"","url":"https://api.github.com/users/mark-buer","html_url":"https://github.com/mark-buer","followers_url":"https://api.github.com/users/mark-buer/followers","following_url":"https://api.github.com/users/mark-buer/following{/other_user}","gists_url":"https://api.github.com/users/mark-buer/gists{/gist_id}","starred_url":"https://api.github.com/users/mark-buer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mark-buer/subscriptions","organizations_url":"https://api.github.com/users/mark-buer/orgs","repos_url":"https://api.github.com/users/mark-buer/repos","events_url":"https://api.github.com/users/mark-buer/events{/privacy}","received_events_url":"https://api.github.com/users/mark-buer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mark-buer/rust","description":"A safe, concurrent, practical language.","fork":true,"url":"https://api.github.com/repos/mark-buer/rust","forks_url":"https://api.github.com/repos/mark-buer/rust/forks","keys_url":"https://api.github.com/repos/mark-buer/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mark-buer/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mark-buer/rust/teams","hooks_url":"https://api.github.com/repos/mark-buer/rust/hooks","issue_events_url":"https://api.github.com/repos/mark-buer/rust/issues/events{/number}","events_url":"https://api.github.com/repos/mark-buer/rust/events","assignees_url":"https://api.github.com/repos/mark-buer/rust/assignees{/user}","branches_url":"https://api.github.com/repos/mark-buer/rust/branches{/branch}","tags_url":"https://api.github.com/repos/mark-buer/rust/tags","blobs_url":"https://api.github.com/repos/mark-buer/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mark-buer/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mark-buer/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/mark-buer/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mark-buer/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/mark-buer/rust/languages","stargazers_url":"https://api.github.com/repos/mark-buer/rust/stargazers","contributors_url":"https://api.github.com/repos/mark-buer/rust/contributors","subscribers_url":"https://api.github.com/repos/mark-buer/rust/subscribers","subscription_url":"https://api.github.com/repos/mark-buer/rust/subscription","commits_url":"https://api.github.com/repos/mark-buer/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/mark-buer/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/mark-buer/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/mark-buer/rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/mark-buer/rust/contents/{+path}","compare_url":"https://api.github.com/repos/mark-buer/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mark-buer/rust/merges","archive_url":"https://api.github.com/repos/mark-buer/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mark-buer/rust/downloads","issues_url":"https://api.github.com/repos/mark-buer/rust/issues{/number}","pulls_url":"https://api.github.com/repos/mark-buer/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/mark-buer/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/mark-buer/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mark-buer/rust/labels{/name}","releases_url":"https://api.github.com/repos/mark-buer/rust/releases{/id}","deployments_url":"https://api.github.com/repos/mark-buer/rust/deployments","created_at":"2015-07-20T23:28:42Z","updated_at":"2016-03-11T22:19:26Z","pushed_at":"2017-06-12T04:15:05Z","git_url":"git://github.com/mark-buer/rust.git","ssh_url":"git@github.com:mark-buer/rust.git","clone_url":"https://github.com/mark-buer/rust.git","svn_url":"https://github.com/mark-buer/rust","homepage":"http://www.rust-lang.org","size":310809,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"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":"rust-lang:master","ref":"master","sha":"29ef41215c2ffe3105ea8cc1621dda00542f65ee","user":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars2.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://avatars2.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}","deployments_url":"https://api.github.com/repos/rust-lang/rust/deployments","created_at":"2010-06-16T20:39:03Z","updated_at":"2017-06-13T02:54:48Z","pushed_at":"2017-06-13T03:41:25Z","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":"https://www.rust-lang.org","size":313044,"stargazers_count":22166,"watchers_count":22166,"language":"Rust","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4103,"mirror_url":null,"open_issues_count":2797,"forks":4103,"open_issues":2797,"watchers":22166,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/42597"},"html":{"href":"https://github.com/rust-lang/rust/pull/42597"},"issue":{"href":"https://api.github.com/repos/rust-lang/rust/issues/42597"},"comments":{"href":"https://api.github.com/repos/rust-lang/rust/issues/42597/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/42597/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/42597/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/rust/statuses/0389d40ce0a891bc7d37ca15c12e23df79d71524"}}}}
{"actor":{"display_login":"mark-buer"}}