{"action":"created","comment":{"url":"https://api.github.com/repos/Workiva/w_common/pulls/comments/146357347","pull_request_review_id":71288227,"id":146357347,"diff_hunk":"@@ -331,13 +364,20 @@ class Disposable implements _Disposable, DisposableManagerV6, LeakFlagger {\n     if (isDisposed) {\n       return null;\n     }\n-    if (_isDisposing) {\n+    if (isDisposalImminent || isDisposing) {\n       return didDispose;\n     }\n-    _isDisposing = true;\n \n-    await Future.wait(_awaitableFutures);\n-    _awaitableFutures.clear();\n+    _isDisposalImminent = true;\n+\n+    while (_awaitableFutures.isNotEmpty) {\n+      final futures = _awaitableFutures.toList();\n+      _awaitableFutures.clear();\n+      await Future.wait(futures);\n+    }\n+\n+    _isDisposing = true;\n+    _isDisposalImminent = false;","path":"lib/src/common/disposable.dart","position":107,"original_position":107,"commit_id":"b286050da44952670e4f6dd944e8a093b0594ab1","original_commit_id":"b286050da44952670e4f6dd944e8a093b0594ab1","user":{"login":"bencampbell-wf","id":11619752,"avatar_url":"https://avatars1.githubusercontent.com/u/11619752?v=4","gravatar_id":"","url":"https://api.github.com/users/bencampbell-wf","html_url":"https://github.com/bencampbell-wf","followers_url":"https://api.github.com/users/bencampbell-wf/followers","following_url":"https://api.github.com/users/bencampbell-wf/following{/other_user}","gists_url":"https://api.github.com/users/bencampbell-wf/gists{/gist_id}","starred_url":"https://api.github.com/users/bencampbell-wf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bencampbell-wf/subscriptions","organizations_url":"https://api.github.com/users/bencampbell-wf/orgs","repos_url":"https://api.github.com/users/bencampbell-wf/repos","events_url":"https://api.github.com/users/bencampbell-wf/events{/privacy}","received_events_url":"https://api.github.com/users/bencampbell-wf/received_events","type":"User","site_admin":false},"body":"FWIW: Setting true/false flags for each state is easy to goof up. Is it better to have an enum mutually exclusive states and use that to set the current state of the disposable object?","created_at":"2017-10-23T18:42:38Z","updated_at":"2017-10-23T18:42:38Z","html_url":"https://github.com/Workiva/w_common/pull/66#discussion_r146357347","pull_request_url":"https://api.github.com/repos/Workiva/w_common/pulls/66","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/Workiva/w_common/pulls/comments/146357347"},"html":{"href":"https://github.com/Workiva/w_common/pull/66#discussion_r146357347"},"pull_request":{"href":"https://api.github.com/repos/Workiva/w_common/pulls/66"}}},"pull_request":{"url":"https://api.github.com/repos/Workiva/w_common/pulls/66","id":147632365,"html_url":"https://github.com/Workiva/w_common/pull/66","diff_url":"https://github.com/Workiva/w_common/pull/66.diff","patch_url":"https://github.com/Workiva/w_common/pull/66.patch","issue_url":"https://api.github.com/repos/Workiva/w_common/issues/66","number":66,"state":"open","locked":false,"title":"Add \"disposal imminent\" step prior to disposal","user":{"login":"evanweible-wf","id":1738457,"avatar_url":"https://avatars2.githubusercontent.com/u/1738457?v=4","gravatar_id":"","url":"https://api.github.com/users/evanweible-wf","html_url":"https://github.com/evanweible-wf","followers_url":"https://api.github.com/users/evanweible-wf/followers","following_url":"https://api.github.com/users/evanweible-wf/following{/other_user}","gists_url":"https://api.github.com/users/evanweible-wf/gists{/gist_id}","starred_url":"https://api.github.com/users/evanweible-wf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evanweible-wf/subscriptions","organizations_url":"https://api.github.com/users/evanweible-wf/orgs","repos_url":"https://api.github.com/users/evanweible-wf/repos","events_url":"https://api.github.com/users/evanweible-wf/events{/privacy}","received_events_url":"https://api.github.com/users/evanweible-wf/received_events","type":"User","site_admin":false},"body":"### Description\r\n\r\nThere are 2 issues being addressed here:\r\n\r\n1. The existing logic around awaitable futures (futures registered via `awaitBeforeDispose`) only waits for the set of futures available when `dispose()` is called – but ignores additional futures registered between calling `dispose()` and when all other awaitable futures have completed.\r\n1. Currently, `isDisposing=true` as soon as `dispose()` is called. However, actual disposal doesn't begin until after the awaitable futures complete. This means that the `Disposable` API is unusable sooner than it needs to be because they check for `isDisposingOrDisposed`.\r\n\r\n### Changes\r\n\r\n- Use a `while` loop to continuously wait for registered futures until there are no more.\r\n- Add an `isDisposalImminent` state that is entered as soon as `dispose()` is called but prior to disposal actually starting. In this state, all of the `Disposable` APIs are still usable and it is perfectly valid to continue processing async tasks.\r\n- Delay the `isDisposing` state until all awaitable futures have completed and disposal is _actually_ in progress.\r\n\r\n### Semantic Versioning\r\n\r\n- [ ] **Patch**\r\n  - [ ] This change does not affect the public API\r\n  - [ ] This change fixes existing incorrect behavior without any additions\r\n- [ ] **Minor**\r\n  - [x] This change adds something to the public API\r\n  - [ ] This change deprecates a part of the public API\r\n* [ ] Major\r\n  - [ ] This change modifies part of the public API in a backwards-incompatible manner\r\n  - [ ] This change removes part of the public API\r\n\r\n### Testing/QA\r\n\r\n- [ ] CI passes\r\n\r\n### Code Review\r\n\r\n@dustinlessard-wf\r\n@evanweible-wf\r\n@jayudey-wf\r\n@maxwellpeterson-wf\r\n@sebastianmalysa-wf\r\n@trentgrover-wf\r\n\r\n","created_at":"2017-10-19T18:32:47Z","updated_at":"2017-10-23T18:42:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"291f2e81e331eaf231f99ec1c1734837905df366","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/Workiva/w_common/pulls/66/commits","review_comments_url":"https://api.github.com/repos/Workiva/w_common/pulls/66/comments","review_comment_url":"https://api.github.com/repos/Workiva/w_common/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Workiva/w_common/issues/66/comments","statuses_url":"https://api.github.com/repos/Workiva/w_common/statuses/b286050da44952670e4f6dd944e8a093b0594ab1","head":{"label":"Workiva:add_imminent_disposal_step","ref":"add_imminent_disposal_step","sha":"b286050da44952670e4f6dd944e8a093b0594ab1","user":{"login":"Workiva","id":1087529,"avatar_url":"https://avatars3.githubusercontent.com/u/1087529?v=4","gravatar_id":"","url":"https://api.github.com/users/Workiva","html_url":"https://github.com/Workiva","followers_url":"https://api.github.com/users/Workiva/followers","following_url":"https://api.github.com/users/Workiva/following{/other_user}","gists_url":"https://api.github.com/users/Workiva/gists{/gist_id}","starred_url":"https://api.github.com/users/Workiva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Workiva/subscriptions","organizations_url":"https://api.github.com/users/Workiva/orgs","repos_url":"https://api.github.com/users/Workiva/repos","events_url":"https://api.github.com/users/Workiva/events{/privacy}","received_events_url":"https://api.github.com/users/Workiva/received_events","type":"Organization","site_admin":false},"repo":{"id":71292440,"name":"w_common","full_name":"Workiva/w_common","owner":{"login":"Workiva","id":1087529,"avatar_url":"https://avatars3.githubusercontent.com/u/1087529?v=4","gravatar_id":"","url":"https://api.github.com/users/Workiva","html_url":"https://github.com/Workiva","followers_url":"https://api.github.com/users/Workiva/followers","following_url":"https://api.github.com/users/Workiva/following{/other_user}","gists_url":"https://api.github.com/users/Workiva/gists{/gist_id}","starred_url":"https://api.github.com/users/Workiva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Workiva/subscriptions","organizations_url":"https://api.github.com/users/Workiva/orgs","repos_url":"https://api.github.com/users/Workiva/repos","events_url":"https://api.github.com/users/Workiva/events{/privacy}","received_events_url":"https://api.github.com/users/Workiva/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Workiva/w_common","description":"A collection of helpful utilities for use in Dart projects.","fork":false,"url":"https://api.github.com/repos/Workiva/w_common","forks_url":"https://api.github.com/repos/Workiva/w_common/forks","keys_url":"https://api.github.com/repos/Workiva/w_common/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Workiva/w_common/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Workiva/w_common/teams","hooks_url":"https://api.github.com/repos/Workiva/w_common/hooks","issue_events_url":"https://api.github.com/repos/Workiva/w_common/issues/events{/number}","events_url":"https://api.github.com/repos/Workiva/w_common/events","assignees_url":"https://api.github.com/repos/Workiva/w_common/assignees{/user}","branches_url":"https://api.github.com/repos/Workiva/w_common/branches{/branch}","tags_url":"https://api.github.com/repos/Workiva/w_common/tags","blobs_url":"https://api.github.com/repos/Workiva/w_common/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Workiva/w_common/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Workiva/w_common/git/refs{/sha}","trees_url":"https://api.github.com/repos/Workiva/w_common/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Workiva/w_common/statuses/{sha}","languages_url":"https://api.github.com/repos/Workiva/w_common/languages","stargazers_url":"https://api.github.com/repos/Workiva/w_common/stargazers","contributors_url":"https://api.github.com/repos/Workiva/w_common/contributors","subscribers_url":"https://api.github.com/repos/Workiva/w_common/subscribers","subscription_url":"https://api.github.com/repos/Workiva/w_common/subscription","commits_url":"https://api.github.com/repos/Workiva/w_common/commits{/sha}","git_commits_url":"https://api.github.com/repos/Workiva/w_common/git/commits{/sha}","comments_url":"https://api.github.com/repos/Workiva/w_common/comments{/number}","issue_comment_url":"https://api.github.com/repos/Workiva/w_common/issues/comments{/number}","contents_url":"https://api.github.com/repos/Workiva/w_common/contents/{+path}","compare_url":"https://api.github.com/repos/Workiva/w_common/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Workiva/w_common/merges","archive_url":"https://api.github.com/repos/Workiva/w_common/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Workiva/w_common/downloads","issues_url":"https://api.github.com/repos/Workiva/w_common/issues{/number}","pulls_url":"https://api.github.com/repos/Workiva/w_common/pulls{/number}","milestones_url":"https://api.github.com/repos/Workiva/w_common/milestones{/number}","notifications_url":"https://api.github.com/repos/Workiva/w_common/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Workiva/w_common/labels{/name}","releases_url":"https://api.github.com/repos/Workiva/w_common/releases{/id}","deployments_url":"https://api.github.com/repos/Workiva/w_common/deployments","created_at":"2016-10-18T21:21:38Z","updated_at":"2017-09-21T18:11:10Z","pushed_at":"2017-10-19T18:34:30Z","git_url":"git://github.com/Workiva/w_common.git","ssh_url":"git@github.com:Workiva/w_common.git","clone_url":"https://github.com/Workiva/w_common.git","svn_url":"https://github.com/Workiva/w_common","homepage":"","size":270,"stargazers_count":2,"watchers_count":2,"language":"Dart","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"Workiva:master","ref":"master","sha":"2480171f2eb60538329dc11df04d28387b35bb3b","user":{"login":"Workiva","id":1087529,"avatar_url":"https://avatars3.githubusercontent.com/u/1087529?v=4","gravatar_id":"","url":"https://api.github.com/users/Workiva","html_url":"https://github.com/Workiva","followers_url":"https://api.github.com/users/Workiva/followers","following_url":"https://api.github.com/users/Workiva/following{/other_user}","gists_url":"https://api.github.com/users/Workiva/gists{/gist_id}","starred_url":"https://api.github.com/users/Workiva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Workiva/subscriptions","organizations_url":"https://api.github.com/users/Workiva/orgs","repos_url":"https://api.github.com/users/Workiva/repos","events_url":"https://api.github.com/users/Workiva/events{/privacy}","received_events_url":"https://api.github.com/users/Workiva/received_events","type":"Organization","site_admin":false},"repo":{"id":71292440,"name":"w_common","full_name":"Workiva/w_common","owner":{"login":"Workiva","id":1087529,"avatar_url":"https://avatars3.githubusercontent.com/u/1087529?v=4","gravatar_id":"","url":"https://api.github.com/users/Workiva","html_url":"https://github.com/Workiva","followers_url":"https://api.github.com/users/Workiva/followers","following_url":"https://api.github.com/users/Workiva/following{/other_user}","gists_url":"https://api.github.com/users/Workiva/gists{/gist_id}","starred_url":"https://api.github.com/users/Workiva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Workiva/subscriptions","organizations_url":"https://api.github.com/users/Workiva/orgs","repos_url":"https://api.github.com/users/Workiva/repos","events_url":"https://api.github.com/users/Workiva/events{/privacy}","received_events_url":"https://api.github.com/users/Workiva/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Workiva/w_common","description":"A collection of helpful utilities for use in Dart projects.","fork":false,"url":"https://api.github.com/repos/Workiva/w_common","forks_url":"https://api.github.com/repos/Workiva/w_common/forks","keys_url":"https://api.github.com/repos/Workiva/w_common/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Workiva/w_common/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Workiva/w_common/teams","hooks_url":"https://api.github.com/repos/Workiva/w_common/hooks","issue_events_url":"https://api.github.com/repos/Workiva/w_common/issues/events{/number}","events_url":"https://api.github.com/repos/Workiva/w_common/events","assignees_url":"https://api.github.com/repos/Workiva/w_common/assignees{/user}","branches_url":"https://api.github.com/repos/Workiva/w_common/branches{/branch}","tags_url":"https://api.github.com/repos/Workiva/w_common/tags","blobs_url":"https://api.github.com/repos/Workiva/w_common/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Workiva/w_common/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Workiva/w_common/git/refs{/sha}","trees_url":"https://api.github.com/repos/Workiva/w_common/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Workiva/w_common/statuses/{sha}","languages_url":"https://api.github.com/repos/Workiva/w_common/languages","stargazers_url":"https://api.github.com/repos/Workiva/w_common/stargazers","contributors_url":"https://api.github.com/repos/Workiva/w_common/contributors","subscribers_url":"https://api.github.com/repos/Workiva/w_common/subscribers","subscription_url":"https://api.github.com/repos/Workiva/w_common/subscription","commits_url":"https://api.github.com/repos/Workiva/w_common/commits{/sha}","git_commits_url":"https://api.github.com/repos/Workiva/w_common/git/commits{/sha}","comments_url":"https://api.github.com/repos/Workiva/w_common/comments{/number}","issue_comment_url":"https://api.github.com/repos/Workiva/w_common/issues/comments{/number}","contents_url":"https://api.github.com/repos/Workiva/w_common/contents/{+path}","compare_url":"https://api.github.com/repos/Workiva/w_common/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Workiva/w_common/merges","archive_url":"https://api.github.com/repos/Workiva/w_common/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Workiva/w_common/downloads","issues_url":"https://api.github.com/repos/Workiva/w_common/issues{/number}","pulls_url":"https://api.github.com/repos/Workiva/w_common/pulls{/number}","milestones_url":"https://api.github.com/repos/Workiva/w_common/milestones{/number}","notifications_url":"https://api.github.com/repos/Workiva/w_common/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Workiva/w_common/labels{/name}","releases_url":"https://api.github.com/repos/Workiva/w_common/releases{/id}","deployments_url":"https://api.github.com/repos/Workiva/w_common/deployments","created_at":"2016-10-18T21:21:38Z","updated_at":"2017-09-21T18:11:10Z","pushed_at":"2017-10-19T18:34:30Z","git_url":"git://github.com/Workiva/w_common.git","ssh_url":"git@github.com:Workiva/w_common.git","clone_url":"https://github.com/Workiva/w_common.git","svn_url":"https://github.com/Workiva/w_common","homepage":"","size":270,"stargazers_count":2,"watchers_count":2,"language":"Dart","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Workiva/w_common/pulls/66"},"html":{"href":"https://github.com/Workiva/w_common/pull/66"},"issue":{"href":"https://api.github.com/repos/Workiva/w_common/issues/66"},"comments":{"href":"https://api.github.com/repos/Workiva/w_common/issues/66/comments"},"review_comments":{"href":"https://api.github.com/repos/Workiva/w_common/pulls/66/comments"},"review_comment":{"href":"https://api.github.com/repos/Workiva/w_common/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Workiva/w_common/pulls/66/commits"},"statuses":{"href":"https://api.github.com/repos/Workiva/w_common/statuses/b286050da44952670e4f6dd944e8a093b0594ab1"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"bencampbell-wf"}}