{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/nan/issues/692","repository_url":"https://api.github.com/repos/nodejs/nan","labels_url":"https://api.github.com/repos/nodejs/nan/issues/692/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/nan/issues/692/comments","events_url":"https://api.github.com/repos/nodejs/nan/issues/692/events","html_url":"https://github.com/nodejs/nan/pull/692","id":255248071,"number":692,"title":"add AsyncProgressQueueWorker to queue and deliver all events","user":{"login":"mkrufky","id":1062488,"avatar_url":"https://avatars3.githubusercontent.com/u/1062488?v=4","gravatar_id":"","url":"https://api.github.com/users/mkrufky","html_url":"https://github.com/mkrufky","followers_url":"https://api.github.com/users/mkrufky/followers","following_url":"https://api.github.com/users/mkrufky/following{/other_user}","gists_url":"https://api.github.com/users/mkrufky/gists{/gist_id}","starred_url":"https://api.github.com/users/mkrufky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkrufky/subscriptions","organizations_url":"https://api.github.com/users/mkrufky/orgs","repos_url":"https://api.github.com/users/mkrufky/repos","events_url":"https://api.github.com/users/mkrufky/events{/privacy}","received_events_url":"https://api.github.com/users/mkrufky/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2017-09-05T11:39:53Z","updated_at":"2017-10-02T10:31:30Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/nodejs/nan/pulls/692","html_url":"https://github.com/nodejs/nan/pull/692","diff_url":"https://github.com/nodejs/nan/pull/692.diff","patch_url":"https://github.com/nodejs/nan/pull/692.patch"},"body":"add `AsyncProgressQueueWorker`: wake the main thread like AsyncProgressWorkerBase, except all events are queued and delivered\r\n\r\nThere are often cases where we want to handle events initiated by threads other than node threads.  Developers are often told to look at `AsyncProgressWorker` , which allows us to send progress updates from external threads, but this is not necessarily enough.  `AsyncProgressWorker` does what it needs to do, but if it is invoked many times before it wakes the main thread, only the last event will be delivered.  This is great for sending \"progress\" style events, but sometimes we need to make sure that all events get delivered.  `AsyncProgressWorker` doesn't do the job in those cases.\r\n\r\nThis PR refactors `AsyncProgressWorkerBase` to separate common elements and adds a new structure, `AsyncProgressQueueWorker` that behaves like `AsyncProgressWorkerBase` except all events are queued and delivered.\r\n\r\n* The first patch, `AsyncProgressWorkerBase inherits AsyncWakeRequestorBase` is a no-op change, that simply separates `AsyncBareProgressWorker` from `AsyncProgressWorkerBase`.\r\n\r\n* The second patch adds the new functionality: `AsyncProgressQueueWorker`\r\n\r\n* The third patch adds a test that shows how `AsyncProgressWorker` can (and will) miss some events.\r\n\r\n* The fourth patch adds tests that show how `AsyncProgressQueueWorker` does not miss events.\r\n\r\n* The later patches fix up the tests for older versions of node on various operating systems and rename the templates to better class names, (originally `AsyncWakeRequestor`, now `AsyncProgressQueueWorker`)\r\n\r\nThe API of `AsyncProgressQueueWorker` is exactly the same as the API of `AsyncProgressWorkerBase`, the only difference is that events will not be missed as a result of multiple wake requests being made before the `uv_async_t` wakes the main thread.  For more info, see the warning at the bottom of the [uv_async_t documentation](http://docs.libuv.org/en/v1.x/async.html):\r\n\r\n> libuv will coalesce calls to uv_async_send(), that is, not every call to it will yield an execution of the callback. For example: if uv_async_send() is called 5 times in a row before the callback is called, the callback will only be called once. If uv_async_send() is called again after the callback was called, it will be called again."},"comment":{"url":"https://api.github.com/repos/nodejs/nan/issues/comments/333497694","html_url":"https://github.com/nodejs/nan/pull/692#issuecomment-333497694","issue_url":"https://api.github.com/repos/nodejs/nan/issues/692","id":333497694,"user":{"login":"bnoordhuis","id":275871,"avatar_url":"https://avatars0.githubusercontent.com/u/275871?v=4","gravatar_id":"","url":"https://api.github.com/users/bnoordhuis","html_url":"https://github.com/bnoordhuis","followers_url":"https://api.github.com/users/bnoordhuis/followers","following_url":"https://api.github.com/users/bnoordhuis/following{/other_user}","gists_url":"https://api.github.com/users/bnoordhuis/gists{/gist_id}","starred_url":"https://api.github.com/users/bnoordhuis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bnoordhuis/subscriptions","organizations_url":"https://api.github.com/users/bnoordhuis/orgs","repos_url":"https://api.github.com/users/bnoordhuis/repos","events_url":"https://api.github.com/users/bnoordhuis/events{/privacy}","received_events_url":"https://api.github.com/users/bnoordhuis/received_events","type":"User","site_admin":false},"created_at":"2017-10-02T10:31:30Z","updated_at":"2017-10-02T10:31:30Z","author_association":"MEMBER","body":"I'll add it to my TBR (To Be Reviewed) list but at +341 −43 it's a bit too big to review right now."}}
{"actor":{"display_login":"bnoordhuis"}}