{"action":"created","comment":{"url":"https://api.github.com/repos/kripken/emscripten/pulls/comments/184549281","pull_request_review_id":115770493,"id":184549281,"diff_hunk":"@@ -126,40 +126,48 @@ int pthread_getattr_np(pthread_t t, pthread_attr_t *a)\n \n static uint32_t dummyZeroAddress = 0;\n \n-static void do_sleep(double msecs)\n+void emscripten_thread_sleep(double msecs)\n {\n-\tint is_main_thread = emscripten_is_main_runtime_thread();\n \tdouble now = emscripten_get_now();\n \tdouble target = now + msecs;\n-#ifdef __EMSCRIPTEN__\n+\n+\t__pthread_testcancel(); // pthreads spec: sleep is a cancellation point, so must test if this thread is cancelled during the sleep.\n+\temscripten_current_thread_process_queued_calls();\n+","path":"system/lib/pthread/library_pthread.c","position":14,"original_position":14,"commit_id":"2a199759aa6b4c87d15d59be21825d3c4fe5bc0f","original_commit_id":"2a199759aa6b4c87d15d59be21825d3c4fe5bc0f","user":{"login":"nickshinpho","id":14188635,"avatar_url":"https://avatars2.githubusercontent.com/u/14188635?v=4","gravatar_id":"","url":"https://api.github.com/users/nickshinpho","html_url":"https://github.com/nickshinpho","followers_url":"https://api.github.com/users/nickshinpho/followers","following_url":"https://api.github.com/users/nickshinpho/following{/other_user}","gists_url":"https://api.github.com/users/nickshinpho/gists{/gist_id}","starred_url":"https://api.github.com/users/nickshinpho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickshinpho/subscriptions","organizations_url":"https://api.github.com/users/nickshinpho/orgs","repos_url":"https://api.github.com/users/nickshinpho/repos","events_url":"https://api.github.com/users/nickshinpho/events{/privacy}","received_events_url":"https://api.github.com/users/nickshinpho/received_events","type":"User","site_admin":false},"body":"note to self: this is defined in #6201 (Multithreading 29/N)","created_at":"2018-04-26T22:30:51Z","updated_at":"2018-04-26T22:30:51Z","html_url":"https://github.com/kripken/emscripten/pull/6195#discussion_r184549281","pull_request_url":"https://api.github.com/repos/kripken/emscripten/pulls/6195","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/kripken/emscripten/pulls/comments/184549281"},"html":{"href":"https://github.com/kripken/emscripten/pull/6195#discussion_r184549281"},"pull_request":{"href":"https://api.github.com/repos/kripken/emscripten/pulls/6195"}}},"pull_request":{"url":"https://api.github.com/repos/kripken/emscripten/pulls/6195","id":167187020,"html_url":"https://github.com/kripken/emscripten/pull/6195","diff_url":"https://github.com/kripken/emscripten/pull/6195.diff","patch_url":"https://github.com/kripken/emscripten/pull/6195.patch","issue_url":"https://api.github.com/repos/kripken/emscripten/issues/6195","number":6195,"state":"open","locked":false,"title":"Multithreading 26/N: emscripten_thread_sleep","user":{"login":"juj","id":225351,"avatar_url":"https://avatars2.githubusercontent.com/u/225351?v=4","gravatar_id":"","url":"https://api.github.com/users/juj","html_url":"https://github.com/juj","followers_url":"https://api.github.com/users/juj/followers","following_url":"https://api.github.com/users/juj/following{/other_user}","gists_url":"https://api.github.com/users/juj/gists{/gist_id}","starred_url":"https://api.github.com/users/juj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juj/subscriptions","organizations_url":"https://api.github.com/users/juj/orgs","repos_url":"https://api.github.com/users/juj/repos","events_url":"https://api.github.com/users/juj/events{/privacy}","received_events_url":"https://api.github.com/users/juj/received_events","type":"User","site_admin":false},"body":"Expose internal do_sleep() as a public `emscripten_thread_sleep()` function.\r\n\r\nThis function is exposed to the main thread as well, since in some lock free structures the only thing one can do is to spinwait for access, even on the main thread, and doing a `emscripten_thread_sleep(0)` inside such loops can improve responsiveness.\r\n\r\nIn a worker thread, this function will save CPU power, since it relies on `Atomics.wait` to do the waiting.","created_at":"2018-02-05T16:14:23Z","updated_at":"2018-04-26T22:30:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cc41bbf66f430847791caaadb8c447da7b19b8f2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":217335058,"url":"https://api.github.com/repos/kripken/emscripten/labels/multithreading","name":"multithreading","color":"DDDDDD","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/kripken/emscripten/pulls/6195/commits","review_comments_url":"https://api.github.com/repos/kripken/emscripten/pulls/6195/comments","review_comment_url":"https://api.github.com/repos/kripken/emscripten/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kripken/emscripten/issues/6195/comments","statuses_url":"https://api.github.com/repos/kripken/emscripten/statuses/2a199759aa6b4c87d15d59be21825d3c4fe5bc0f","head":{"label":"juj:emscripten_thread_sleep","ref":"emscripten_thread_sleep","sha":"2a199759aa6b4c87d15d59be21825d3c4fe5bc0f","user":{"login":"juj","id":225351,"avatar_url":"https://avatars2.githubusercontent.com/u/225351?v=4","gravatar_id":"","url":"https://api.github.com/users/juj","html_url":"https://github.com/juj","followers_url":"https://api.github.com/users/juj/followers","following_url":"https://api.github.com/users/juj/following{/other_user}","gists_url":"https://api.github.com/users/juj/gists{/gist_id}","starred_url":"https://api.github.com/users/juj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juj/subscriptions","organizations_url":"https://api.github.com/users/juj/orgs","repos_url":"https://api.github.com/users/juj/repos","events_url":"https://api.github.com/users/juj/events{/privacy}","received_events_url":"https://api.github.com/users/juj/received_events","type":"User","site_admin":false},"repo":{"id":4149606,"name":"emscripten","full_name":"juj/emscripten","owner":{"login":"juj","id":225351,"avatar_url":"https://avatars2.githubusercontent.com/u/225351?v=4","gravatar_id":"","url":"https://api.github.com/users/juj","html_url":"https://github.com/juj","followers_url":"https://api.github.com/users/juj/followers","following_url":"https://api.github.com/users/juj/following{/other_user}","gists_url":"https://api.github.com/users/juj/gists{/gist_id}","starred_url":"https://api.github.com/users/juj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juj/subscriptions","organizations_url":"https://api.github.com/users/juj/orgs","repos_url":"https://api.github.com/users/juj/repos","events_url":"https://api.github.com/users/juj/events{/privacy}","received_events_url":"https://api.github.com/users/juj/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/juj/emscripten","description":"Emscripten: An LLVM-to-JavaScript Compiler","fork":true,"url":"https://api.github.com/repos/juj/emscripten","forks_url":"https://api.github.com/repos/juj/emscripten/forks","keys_url":"https://api.github.com/repos/juj/emscripten/keys{/key_id}","collaborators_url":"https://api.github.com/repos/juj/emscripten/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/juj/emscripten/teams","hooks_url":"https://api.github.com/repos/juj/emscripten/hooks","issue_events_url":"https://api.github.com/repos/juj/emscripten/issues/events{/number}","events_url":"https://api.github.com/repos/juj/emscripten/events","assignees_url":"https://api.github.com/repos/juj/emscripten/assignees{/user}","branches_url":"https://api.github.com/repos/juj/emscripten/branches{/branch}","tags_url":"https://api.github.com/repos/juj/emscripten/tags","blobs_url":"https://api.github.com/repos/juj/emscripten/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/juj/emscripten/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/juj/emscripten/git/refs{/sha}","trees_url":"https://api.github.com/repos/juj/emscripten/git/trees{/sha}","statuses_url":"https://api.github.com/repos/juj/emscripten/statuses/{sha}","languages_url":"https://api.github.com/repos/juj/emscripten/languages","stargazers_url":"https://api.github.com/repos/juj/emscripten/stargazers","contributors_url":"https://api.github.com/repos/juj/emscripten/contributors","subscribers_url":"https://api.github.com/repos/juj/emscripten/subscribers","subscription_url":"https://api.github.com/repos/juj/emscripten/subscription","commits_url":"https://api.github.com/repos/juj/emscripten/commits{/sha}","git_commits_url":"https://api.github.com/repos/juj/emscripten/git/commits{/sha}","comments_url":"https://api.github.com/repos/juj/emscripten/comments{/number}","issue_comment_url":"https://api.github.com/repos/juj/emscripten/issues/comments{/number}","contents_url":"https://api.github.com/repos/juj/emscripten/contents/{+path}","compare_url":"https://api.github.com/repos/juj/emscripten/compare/{base}...{head}","merges_url":"https://api.github.com/repos/juj/emscripten/merges","archive_url":"https://api.github.com/repos/juj/emscripten/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/juj/emscripten/downloads","issues_url":"https://api.github.com/repos/juj/emscripten/issues{/number}","pulls_url":"https://api.github.com/repos/juj/emscripten/pulls{/number}","milestones_url":"https://api.github.com/repos/juj/emscripten/milestones{/number}","notifications_url":"https://api.github.com/repos/juj/emscripten/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/juj/emscripten/labels{/name}","releases_url":"https://api.github.com/repos/juj/emscripten/releases{/id}","deployments_url":"https://api.github.com/repos/juj/emscripten/deployments","created_at":"2012-04-26T16:19:07Z","updated_at":"2017-03-09T08:12:20Z","pushed_at":"2018-03-07T14:40:03Z","git_url":"git://github.com/juj/emscripten.git","ssh_url":"git@github.com:juj/emscripten.git","clone_url":"https://github.com/juj/emscripten.git","svn_url":"https://github.com/juj/emscripten","homepage":"","size":155094,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":4,"default_branch":"master"}},"base":{"label":"kripken:incoming","ref":"incoming","sha":"fa703b7390d3a790269eed9eeb3b56bb1b619d71","user":{"login":"kripken","id":173661,"avatar_url":"https://avatars0.githubusercontent.com/u/173661?v=4","gravatar_id":"","url":"https://api.github.com/users/kripken","html_url":"https://github.com/kripken","followers_url":"https://api.github.com/users/kripken/followers","following_url":"https://api.github.com/users/kripken/following{/other_user}","gists_url":"https://api.github.com/users/kripken/gists{/gist_id}","starred_url":"https://api.github.com/users/kripken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kripken/subscriptions","organizations_url":"https://api.github.com/users/kripken/orgs","repos_url":"https://api.github.com/users/kripken/repos","events_url":"https://api.github.com/users/kripken/events{/privacy}","received_events_url":"https://api.github.com/users/kripken/received_events","type":"User","site_admin":false},"repo":{"id":1357796,"name":"emscripten","full_name":"kripken/emscripten","owner":{"login":"kripken","id":173661,"avatar_url":"https://avatars0.githubusercontent.com/u/173661?v=4","gravatar_id":"","url":"https://api.github.com/users/kripken","html_url":"https://github.com/kripken","followers_url":"https://api.github.com/users/kripken/followers","following_url":"https://api.github.com/users/kripken/following{/other_user}","gists_url":"https://api.github.com/users/kripken/gists{/gist_id}","starred_url":"https://api.github.com/users/kripken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kripken/subscriptions","organizations_url":"https://api.github.com/users/kripken/orgs","repos_url":"https://api.github.com/users/kripken/repos","events_url":"https://api.github.com/users/kripken/events{/privacy}","received_events_url":"https://api.github.com/users/kripken/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kripken/emscripten","description":"Emscripten: An LLVM-to-JavaScript Compiler","fork":false,"url":"https://api.github.com/repos/kripken/emscripten","forks_url":"https://api.github.com/repos/kripken/emscripten/forks","keys_url":"https://api.github.com/repos/kripken/emscripten/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kripken/emscripten/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kripken/emscripten/teams","hooks_url":"https://api.github.com/repos/kripken/emscripten/hooks","issue_events_url":"https://api.github.com/repos/kripken/emscripten/issues/events{/number}","events_url":"https://api.github.com/repos/kripken/emscripten/events","assignees_url":"https://api.github.com/repos/kripken/emscripten/assignees{/user}","branches_url":"https://api.github.com/repos/kripken/emscripten/branches{/branch}","tags_url":"https://api.github.com/repos/kripken/emscripten/tags","blobs_url":"https://api.github.com/repos/kripken/emscripten/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kripken/emscripten/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kripken/emscripten/git/refs{/sha}","trees_url":"https://api.github.com/repos/kripken/emscripten/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kripken/emscripten/statuses/{sha}","languages_url":"https://api.github.com/repos/kripken/emscripten/languages","stargazers_url":"https://api.github.com/repos/kripken/emscripten/stargazers","contributors_url":"https://api.github.com/repos/kripken/emscripten/contributors","subscribers_url":"https://api.github.com/repos/kripken/emscripten/subscribers","subscription_url":"https://api.github.com/repos/kripken/emscripten/subscription","commits_url":"https://api.github.com/repos/kripken/emscripten/commits{/sha}","git_commits_url":"https://api.github.com/repos/kripken/emscripten/git/commits{/sha}","comments_url":"https://api.github.com/repos/kripken/emscripten/comments{/number}","issue_comment_url":"https://api.github.com/repos/kripken/emscripten/issues/comments{/number}","contents_url":"https://api.github.com/repos/kripken/emscripten/contents/{+path}","compare_url":"https://api.github.com/repos/kripken/emscripten/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kripken/emscripten/merges","archive_url":"https://api.github.com/repos/kripken/emscripten/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kripken/emscripten/downloads","issues_url":"https://api.github.com/repos/kripken/emscripten/issues{/number}","pulls_url":"https://api.github.com/repos/kripken/emscripten/pulls{/number}","milestones_url":"https://api.github.com/repos/kripken/emscripten/milestones{/number}","notifications_url":"https://api.github.com/repos/kripken/emscripten/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kripken/emscripten/labels{/name}","releases_url":"https://api.github.com/repos/kripken/emscripten/releases{/id}","deployments_url":"https://api.github.com/repos/kripken/emscripten/deployments","created_at":"2011-02-12T05:23:30Z","updated_at":"2018-04-26T15:35:20Z","pushed_at":"2018-04-26T18:06:16Z","git_url":"git://github.com/kripken/emscripten.git","ssh_url":"git@github.com:kripken/emscripten.git","clone_url":"https://github.com/kripken/emscripten.git","svn_url":"https://github.com/kripken/emscripten","homepage":"","size":159145,"stargazers_count":14530,"watchers_count":14530,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1718,"mirror_url":null,"archived":false,"open_issues_count":1435,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":1718,"open_issues":1435,"watchers":14530,"default_branch":"incoming"}},"_links":{"self":{"href":"https://api.github.com/repos/kripken/emscripten/pulls/6195"},"html":{"href":"https://github.com/kripken/emscripten/pull/6195"},"issue":{"href":"https://api.github.com/repos/kripken/emscripten/issues/6195"},"comments":{"href":"https://api.github.com/repos/kripken/emscripten/issues/6195/comments"},"review_comments":{"href":"https://api.github.com/repos/kripken/emscripten/pulls/6195/comments"},"review_comment":{"href":"https://api.github.com/repos/kripken/emscripten/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kripken/emscripten/pulls/6195/commits"},"statuses":{"href":"https://api.github.com/repos/kripken/emscripten/statuses/2a199759aa6b4c87d15d59be21825d3c4fe5bc0f"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"nickshinpho"}}