{"action":"created","comment":{"url":"https://api.github.com/repos/nodejs/node-eps/pulls/comments/62125227","id":62125227,"diff_hunk":"@@ -0,0 +1,309 @@\n+| Title  | AsyncWrap API |\n+|--------|---------------|\n+| Author | @trevnorris   |\n+| Status | DRAFT         |\n+| Date   | 2016-04-05    |\n+\n+## Description\n+\n+Since its initial introduction with the `AsyncListener` API, `AsyncWrap` has\n+slowly evolved to ensure a generalized API that would serve as a solid base for\n+module authors who wished to add events to the life cycle of the event loop.\n+The API presented below aims to accomplish this.\n+\n+## API\n+\n+### Overview\n+\n+```js\n+// Standard way of requiring a module. Snake case follows core module\n+// convention.\n+const async_wrap = require('async_wrap');\n+\n+// List of asynchronous providers (e.g. CRYPTO or TCPWRAP). Can be used for\n+// trace filtering of events.\n+const providers = async_wrap.Providers;\n+\n+// init() is called during object construction. The object handle being\n+// constructed can be accessed as \"this\". Because init() is called during\n+// construction it is not safe to blindly inspect the constructed object at the\n+// moment. Though we are currently investigating how to make this safe.\n+function init(id, type, parentId) { }\n+\n+// pre() is called just before the handle's callback is called. It can be\n+// called 0-N times for handles (e.g. TCPWRAP), and should be called exactly 1\n+// time for requests (e.g. FSREQWRAP).\n+function pre(id) { }","path":"XXX-asyncwrap-api.md","position":36,"original_position":36,"commit_id":"762c337b9088b3df4d39ca15de154ee467eb6fa5","original_commit_id":"762c337b9088b3df4d39ca15de154ee467eb6fa5","user":{"login":"trevnorris","id":289174,"avatar_url":"https://avatars.githubusercontent.com/u/289174?v=3","gravatar_id":"","url":"https://api.github.com/users/trevnorris","html_url":"https://github.com/trevnorris","followers_url":"https://api.github.com/users/trevnorris/followers","following_url":"https://api.github.com/users/trevnorris/following{/other_user}","gists_url":"https://api.github.com/users/trevnorris/gists{/gist_id}","starred_url":"https://api.github.com/users/trevnorris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trevnorris/subscriptions","organizations_url":"https://api.github.com/users/trevnorris/orgs","repos_url":"https://api.github.com/users/trevnorris/repos","events_url":"https://api.github.com/users/trevnorris/events{/privacy}","received_events_url":"https://api.github.com/users/trevnorris/received_events","type":"User","site_admin":false},"body":"> Not clear how that will work for the `destroy()` case where there is no handle\r\n\r\nThere's always a handle. Just not passed in `destroy()` to prevent accidental abort, but I'm currently working on fixing this so the instance can be safely accessed at any time.\r\n\r\n> Such a type can evolve to include appropriate information such as the type, handle-specific state, etc...\r\n\r\nAll this information already lives in the native layer. It would be far more cost effective and less complicated to query that information.\r\n\r\n> The other useful bit of information is the _invocation count_. i.e., in cases where pre()/post() can be called 0..n times, what will uniquely identify an invocation?\r\n\r\nThe invocation count can be easily enough tracked by the user by a combination of tracking each request id to each handle that created it, and then when `pre()` is called by the request. Those are mechanics that are too specific for the initial implementation. I don't understand what you mean by \"uniquely identify an invocation\".\r\n\r\n>  I agree that this can be tracked by individually by the hooks, but it is part of the identity of an invocation of a callback. (i.e., an execution of a callback is uniquely identifed by the tuple [asyncId, invocationId])\r\n\r\nThe point of this API at this moment is to offer only that which can't be gained by any other means (with exception to `.scope()`, but added to prevent easily hazardous scenarios). I'm not sure what you mean by `invocationId`. If you simply mean a unique id for every call to `MakeCallback()` that would be the simplest piece of information to track in user land. A simple `invocationId++;` would do the trick.\r\n\r\nThough I think what you may be asking for is assigning an `invocationId` in the `init()` area so it can be tracked and identified in the `pre()`. Is this correct?","created_at":"2016-05-04T22:23:51Z","updated_at":"2016-05-04T22:23:51Z","html_url":"https://github.com/nodejs/node-eps/pull/18#discussion_r62125227","pull_request_url":"https://api.github.com/repos/nodejs/node-eps/pulls/18","_links":{"self":{"href":"https://api.github.com/repos/nodejs/node-eps/pulls/comments/62125227"},"html":{"href":"https://github.com/nodejs/node-eps/pull/18#discussion_r62125227"},"pull_request":{"href":"https://api.github.com/repos/nodejs/node-eps/pulls/18"}}},"pull_request":{"url":"https://api.github.com/repos/nodejs/node-eps/pulls/18","id":68137447,"html_url":"https://github.com/nodejs/node-eps/pull/18","diff_url":"https://github.com/nodejs/node-eps/pull/18.diff","patch_url":"https://github.com/nodejs/node-eps/pull/18.patch","issue_url":"https://api.github.com/repos/nodejs/node-eps/issues/18","number":18,"state":"open","locked":false,"title":"AsyncWrap public API proposal","user":{"login":"trevnorris","id":289174,"avatar_url":"https://avatars.githubusercontent.com/u/289174?v=3","gravatar_id":"","url":"https://api.github.com/users/trevnorris","html_url":"https://github.com/trevnorris","followers_url":"https://api.github.com/users/trevnorris/followers","following_url":"https://api.github.com/users/trevnorris/following{/other_user}","gists_url":"https://api.github.com/users/trevnorris/gists{/gist_id}","starred_url":"https://api.github.com/users/trevnorris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trevnorris/subscriptions","organizations_url":"https://api.github.com/users/trevnorris/orgs","repos_url":"https://api.github.com/users/trevnorris/repos","events_url":"https://api.github.com/users/trevnorris/events{/privacy}","received_events_url":"https://api.github.com/users/trevnorris/received_events","type":"User","site_admin":false},"body":"After much investigation and communication this is the API that has\r\nsurfaced. Meant to be minimal, not impose any performance penalty to\r\ncore when not being used, and minimal impact when it is used, this\r\nshould serve public needs that have been expressed over the last two\r\nyears.\r\n\r\n@nodejs/ctc I'd like the initial review explicitly from the CTC before this is opened for too much external debate. Because experience has shown me that there will be suggestions/changes for those who want specific features and/or additions to suit their specific use case. Usually not taking the time to realize that this API is enough. They just need to write the additional code for the hooks.","created_at":"2016-04-27T22:43:35Z","updated_at":"2016-05-04T22:23:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"79963dbb968a8dd9891851b571fd265f718041a5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nodejs/node-eps/pulls/18/commits","review_comments_url":"https://api.github.com/repos/nodejs/node-eps/pulls/18/comments","review_comment_url":"https://api.github.com/repos/nodejs/node-eps/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nodejs/node-eps/issues/18/comments","statuses_url":"https://api.github.com/repos/nodejs/node-eps/statuses/762c337b9088b3df4d39ca15de154ee467eb6fa5","head":{"label":"nodejs:async-wrap-ep","ref":"async-wrap-ep","sha":"762c337b9088b3df4d39ca15de154ee467eb6fa5","user":{"login":"nodejs","id":9950313,"avatar_url":"https://avatars.githubusercontent.com/u/9950313?v=3","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"repo":{"id":48204104,"name":"node-eps","full_name":"nodejs/node-eps","owner":{"login":"nodejs","id":9950313,"avatar_url":"https://avatars.githubusercontent.com/u/9950313?v=3","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nodejs/node-eps","description":"Node.js Enhancement Proposals for discussion on future API additions/changes to Node core","fork":false,"url":"https://api.github.com/repos/nodejs/node-eps","forks_url":"https://api.github.com/repos/nodejs/node-eps/forks","keys_url":"https://api.github.com/repos/nodejs/node-eps/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nodejs/node-eps/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nodejs/node-eps/teams","hooks_url":"https://api.github.com/repos/nodejs/node-eps/hooks","issue_events_url":"https://api.github.com/repos/nodejs/node-eps/issues/events{/number}","events_url":"https://api.github.com/repos/nodejs/node-eps/events","assignees_url":"https://api.github.com/repos/nodejs/node-eps/assignees{/user}","branches_url":"https://api.github.com/repos/nodejs/node-eps/branches{/branch}","tags_url":"https://api.github.com/repos/nodejs/node-eps/tags","blobs_url":"https://api.github.com/repos/nodejs/node-eps/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nodejs/node-eps/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nodejs/node-eps/git/refs{/sha}","trees_url":"https://api.github.com/repos/nodejs/node-eps/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nodejs/node-eps/statuses/{sha}","languages_url":"https://api.github.com/repos/nodejs/node-eps/languages","stargazers_url":"https://api.github.com/repos/nodejs/node-eps/stargazers","contributors_url":"https://api.github.com/repos/nodejs/node-eps/contributors","subscribers_url":"https://api.github.com/repos/nodejs/node-eps/subscribers","subscription_url":"https://api.github.com/repos/nodejs/node-eps/subscription","commits_url":"https://api.github.com/repos/nodejs/node-eps/commits{/sha}","git_commits_url":"https://api.github.com/repos/nodejs/node-eps/git/commits{/sha}","comments_url":"https://api.github.com/repos/nodejs/node-eps/comments{/number}","issue_comment_url":"https://api.github.com/repos/nodejs/node-eps/issues/comments{/number}","contents_url":"https://api.github.com/repos/nodejs/node-eps/contents/{+path}","compare_url":"https://api.github.com/repos/nodejs/node-eps/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nodejs/node-eps/merges","archive_url":"https://api.github.com/repos/nodejs/node-eps/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nodejs/node-eps/downloads","issues_url":"https://api.github.com/repos/nodejs/node-eps/issues{/number}","pulls_url":"https://api.github.com/repos/nodejs/node-eps/pulls{/number}","milestones_url":"https://api.github.com/repos/nodejs/node-eps/milestones{/number}","notifications_url":"https://api.github.com/repos/nodejs/node-eps/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nodejs/node-eps/labels{/name}","releases_url":"https://api.github.com/repos/nodejs/node-eps/releases{/id}","deployments_url":"https://api.github.com/repos/nodejs/node-eps/deployments","created_at":"2015-12-17T23:39:07Z","updated_at":"2016-05-02T22:38:55Z","pushed_at":"2016-05-04T18:17:01Z","git_url":"git://github.com/nodejs/node-eps.git","ssh_url":"git@github.com:nodejs/node-eps.git","clone_url":"https://github.com/nodejs/node-eps.git","svn_url":"https://github.com/nodejs/node-eps","homepage":null,"size":71,"stargazers_count":81,"watchers_count":81,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":11,"forks":12,"open_issues":11,"watchers":81,"default_branch":"master"}},"base":{"label":"nodejs:master","ref":"master","sha":"8e2ac8ffbe17c837ffa9546f9324727040d0ebce","user":{"login":"nodejs","id":9950313,"avatar_url":"https://avatars.githubusercontent.com/u/9950313?v=3","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"repo":{"id":48204104,"name":"node-eps","full_name":"nodejs/node-eps","owner":{"login":"nodejs","id":9950313,"avatar_url":"https://avatars.githubusercontent.com/u/9950313?v=3","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nodejs/node-eps","description":"Node.js Enhancement Proposals for discussion on future API additions/changes to Node core","fork":false,"url":"https://api.github.com/repos/nodejs/node-eps","forks_url":"https://api.github.com/repos/nodejs/node-eps/forks","keys_url":"https://api.github.com/repos/nodejs/node-eps/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nodejs/node-eps/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nodejs/node-eps/teams","hooks_url":"https://api.github.com/repos/nodejs/node-eps/hooks","issue_events_url":"https://api.github.com/repos/nodejs/node-eps/issues/events{/number}","events_url":"https://api.github.com/repos/nodejs/node-eps/events","assignees_url":"https://api.github.com/repos/nodejs/node-eps/assignees{/user}","branches_url":"https://api.github.com/repos/nodejs/node-eps/branches{/branch}","tags_url":"https://api.github.com/repos/nodejs/node-eps/tags","blobs_url":"https://api.github.com/repos/nodejs/node-eps/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nodejs/node-eps/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nodejs/node-eps/git/refs{/sha}","trees_url":"https://api.github.com/repos/nodejs/node-eps/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nodejs/node-eps/statuses/{sha}","languages_url":"https://api.github.com/repos/nodejs/node-eps/languages","stargazers_url":"https://api.github.com/repos/nodejs/node-eps/stargazers","contributors_url":"https://api.github.com/repos/nodejs/node-eps/contributors","subscribers_url":"https://api.github.com/repos/nodejs/node-eps/subscribers","subscription_url":"https://api.github.com/repos/nodejs/node-eps/subscription","commits_url":"https://api.github.com/repos/nodejs/node-eps/commits{/sha}","git_commits_url":"https://api.github.com/repos/nodejs/node-eps/git/commits{/sha}","comments_url":"https://api.github.com/repos/nodejs/node-eps/comments{/number}","issue_comment_url":"https://api.github.com/repos/nodejs/node-eps/issues/comments{/number}","contents_url":"https://api.github.com/repos/nodejs/node-eps/contents/{+path}","compare_url":"https://api.github.com/repos/nodejs/node-eps/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nodejs/node-eps/merges","archive_url":"https://api.github.com/repos/nodejs/node-eps/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nodejs/node-eps/downloads","issues_url":"https://api.github.com/repos/nodejs/node-eps/issues{/number}","pulls_url":"https://api.github.com/repos/nodejs/node-eps/pulls{/number}","milestones_url":"https://api.github.com/repos/nodejs/node-eps/milestones{/number}","notifications_url":"https://api.github.com/repos/nodejs/node-eps/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nodejs/node-eps/labels{/name}","releases_url":"https://api.github.com/repos/nodejs/node-eps/releases{/id}","deployments_url":"https://api.github.com/repos/nodejs/node-eps/deployments","created_at":"2015-12-17T23:39:07Z","updated_at":"2016-05-02T22:38:55Z","pushed_at":"2016-05-04T18:17:01Z","git_url":"git://github.com/nodejs/node-eps.git","ssh_url":"git@github.com:nodejs/node-eps.git","clone_url":"https://github.com/nodejs/node-eps.git","svn_url":"https://github.com/nodejs/node-eps","homepage":null,"size":71,"stargazers_count":81,"watchers_count":81,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":11,"forks":12,"open_issues":11,"watchers":81,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nodejs/node-eps/pulls/18"},"html":{"href":"https://github.com/nodejs/node-eps/pull/18"},"issue":{"href":"https://api.github.com/repos/nodejs/node-eps/issues/18"},"comments":{"href":"https://api.github.com/repos/nodejs/node-eps/issues/18/comments"},"review_comments":{"href":"https://api.github.com/repos/nodejs/node-eps/pulls/18/comments"},"review_comment":{"href":"https://api.github.com/repos/nodejs/node-eps/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nodejs/node-eps/pulls/18/commits"},"statuses":{"href":"https://api.github.com/repos/nodejs/node-eps/statuses/762c337b9088b3df4d39ca15de154ee467eb6fa5"}}}}