{"action":"created","comment":{"url":"https://api.github.com/repos/nunit/nunit/pulls/comments/61010724","id":61010724,"diff_hunk":"@@ -112,46 +117,53 @@ public override IList<ITestResult> Children\n         /// <param name=\"result\">The result to be added</param>\n         public virtual void AddResult(ITestResult result)\n         {\n-            Children.Add(result);\n+            Children.Enqueue(result);\n \n             //AssertCount += result.AssertCount;\n \n-            // If this result is marked cancelled, don't change it\n-            if (ResultState != ResultState.Cancelled)\n+            bool stateSet;\n+            do\n+            {\n+                stateSet = true;\n+\n+                var resultState = ResultState;\n+\n+                // If this result is marked cancelled, don't change it\n+                if (resultState == ResultState.Cancelled)\n+                    break;\n+\n                 switch (result.ResultState.Status)\n                 {\n                     case TestStatus.Passed:\n \n-                        if (ResultState.Status == TestStatus.Inconclusive)\n-                            SetResult(ResultState.Success);\n+                        if (resultState.Status == TestStatus.Inconclusive)\n+                            stateSet = SetResultIf(resultState, ResultState.Success);\n \n                         break;\n \n                     case TestStatus.Failed:\n \n \n-                        if (ResultState.Status != TestStatus.Failed)\n-                            SetResult(ResultState.ChildFailure, CHILD_ERRORS_MESSAGE);\n+                        if (resultState.Status != TestStatus.Failed)\n+                            stateSet = SetResultIf(resultState, ResultState.ChildFailure, CHILD_ERRORS_MESSAGE);\n \n                         break;\n \n                     case TestStatus.Skipped:\n \n                         if (result.ResultState.Label == \"Ignored\")\n-                            if (ResultState.Status == TestStatus.Inconclusive || ResultState.Status == TestStatus.Passed)\n-                                SetResult(ResultState.Ignored, CHILD_IGNORE_MESSAGE);\n-\n-                        break;\n+                            if (resultState.Status == TestStatus.Inconclusive || resultState.Status == TestStatus.Passed)\n+                                stateSet = SetResultIf(resultState, ResultState.Ignored, CHILD_IGNORE_MESSAGE);\n \n-                    default:\n                         break;\n                 }\n+            } while (!stateSet);\n \n-            AssertCount += result.AssertCount;\n-            _passCount += result.PassCount;\n-            _failCount += result.FailCount;\n-            _skipCount += result.SkipCount;\n-            _inconclusiveCount += result.InconclusiveCount;\n+            Interlocked.Add (ref InternalAssertCount, result.AssertCount);\n+            Interlocked.Add (ref _passCount, result.PassCount);\n+            Interlocked.Add (ref _failCount, result.FailCount);\n+            Interlocked.Add (ref _skipCount, result.SkipCount);\n+            Interlocked.Add (ref _inconclusiveCount, result.InconclusiveCount);\n         }\n ","path":"src/NUnitFramework/framework/Internal/Results/TestSuiteResult.cs","position":154,"original_position":116,"commit_id":"04ddbd2bc4c779c3d9576ac5ca95a31d8aca37dc","original_commit_id":"8a02be631e0caf34af8910e01123d4f4684efe1d","user":{"login":"oznetmaster","id":5798625,"avatar_url":"https://avatars.githubusercontent.com/u/5798625?v=3","gravatar_id":"","url":"https://api.github.com/users/oznetmaster","html_url":"https://github.com/oznetmaster","followers_url":"https://api.github.com/users/oznetmaster/followers","following_url":"https://api.github.com/users/oznetmaster/following{/other_user}","gists_url":"https://api.github.com/users/oznetmaster/gists{/gist_id}","starred_url":"https://api.github.com/users/oznetmaster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oznetmaster/subscriptions","organizations_url":"https://api.github.com/users/oznetmaster/orgs","repos_url":"https://api.github.com/users/oznetmaster/repos","events_url":"https://api.github.com/users/oznetmaster/events{/privacy}","received_events_url":"https://api.github.com/users/oznetmaster/received_events","type":"User","site_admin":false},"body":"Unless every property of ITestResult was locked individually, there is no way to provide consistent results to a reading thread.  Even if AddResult used a lock to make the entire method atomic, another thread could still access any of the counts, and they would not be consistent.\r\n\r\nIf that is the real issue, then each property should have a read lock, and AddResult should have a write lock.  That can be done using ReaderWriterLock or ReaderWriterLockSlim.","created_at":"2016-04-25T23:59:49Z","updated_at":"2016-04-25T23:59:49Z","html_url":"https://github.com/nunit/nunit/pull/1452#discussion_r61010724","pull_request_url":"https://api.github.com/repos/nunit/nunit/pulls/1452","_links":{"self":{"href":"https://api.github.com/repos/nunit/nunit/pulls/comments/61010724"},"html":{"href":"https://github.com/nunit/nunit/pull/1452#discussion_r61010724"},"pull_request":{"href":"https://api.github.com/repos/nunit/nunit/pulls/1452"}}},"pull_request":{"url":"https://api.github.com/repos/nunit/nunit/pulls/1452","id":67657352,"html_url":"https://github.com/nunit/nunit/pull/1452","diff_url":"https://github.com/nunit/nunit/pull/1452.diff","patch_url":"https://github.com/nunit/nunit/pull/1452.patch","issue_url":"https://api.github.com/repos/nunit/nunit/issues/1452","number":1452,"state":"open","locked":false,"title":"Fix issue #1434","user":{"login":"oznetmaster","id":5798625,"avatar_url":"https://avatars.githubusercontent.com/u/5798625?v=3","gravatar_id":"","url":"https://api.github.com/users/oznetmaster","html_url":"https://github.com/oznetmaster","followers_url":"https://api.github.com/users/oznetmaster/followers","following_url":"https://api.github.com/users/oznetmaster/following{/other_user}","gists_url":"https://api.github.com/users/oznetmaster/gists{/gist_id}","starred_url":"https://api.github.com/users/oznetmaster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oznetmaster/subscriptions","organizations_url":"https://api.github.com/users/oznetmaster/orgs","repos_url":"https://api.github.com/users/oznetmaster/repos","events_url":"https://api.github.com/users/oznetmaster/events{/privacy}","received_events_url":"https://api.github.com/users/oznetmaster/received_events","type":"User","site_admin":false},"body":"This PR adds the mono ConcurrentQueue class to all builds for which it\r\nis not available.  It uses the ConcurrentQueue and Interlocked classes\r\nto make the TestResult class (and its derivatives) thread safe.\r\n\r\nIt also adds an Interlocked.Add method to the CF build, since it is not available in CF.","created_at":"2016-04-25T01:36:49Z","updated_at":"2016-04-25T23:59:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"24f82ec467742d4d71d50c4faa8adf9ed4dfa779","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nunit/nunit/pulls/1452/commits","review_comments_url":"https://api.github.com/repos/nunit/nunit/pulls/1452/comments","review_comment_url":"https://api.github.com/repos/nunit/nunit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nunit/nunit/issues/1452/comments","statuses_url":"https://api.github.com/repos/nunit/nunit/statuses/04ddbd2bc4c779c3d9576ac5ca95a31d8aca37dc","head":{"label":"nunit:issue-1434","ref":"issue-1434","sha":"04ddbd2bc4c779c3d9576ac5ca95a31d8aca37dc","user":{"login":"nunit","id":2678858,"avatar_url":"https://avatars.githubusercontent.com/u/2678858?v=3","gravatar_id":"","url":"https://api.github.com/users/nunit","html_url":"https://github.com/nunit","followers_url":"https://api.github.com/users/nunit/followers","following_url":"https://api.github.com/users/nunit/following{/other_user}","gists_url":"https://api.github.com/users/nunit/gists{/gist_id}","starred_url":"https://api.github.com/users/nunit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nunit/subscriptions","organizations_url":"https://api.github.com/users/nunit/orgs","repos_url":"https://api.github.com/users/nunit/repos","events_url":"https://api.github.com/users/nunit/events{/privacy}","received_events_url":"https://api.github.com/users/nunit/received_events","type":"Organization","site_admin":false},"repo":{"id":13692183,"name":"nunit","full_name":"nunit/nunit","owner":{"login":"nunit","id":2678858,"avatar_url":"https://avatars.githubusercontent.com/u/2678858?v=3","gravatar_id":"","url":"https://api.github.com/users/nunit","html_url":"https://github.com/nunit","followers_url":"https://api.github.com/users/nunit/followers","following_url":"https://api.github.com/users/nunit/following{/other_user}","gists_url":"https://api.github.com/users/nunit/gists{/gist_id}","starred_url":"https://api.github.com/users/nunit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nunit/subscriptions","organizations_url":"https://api.github.com/users/nunit/orgs","repos_url":"https://api.github.com/users/nunit/repos","events_url":"https://api.github.com/users/nunit/events{/privacy}","received_events_url":"https://api.github.com/users/nunit/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nunit/nunit","description":"NUnit 3.0 framework, engine and console runner","fork":false,"url":"https://api.github.com/repos/nunit/nunit","forks_url":"https://api.github.com/repos/nunit/nunit/forks","keys_url":"https://api.github.com/repos/nunit/nunit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nunit/nunit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nunit/nunit/teams","hooks_url":"https://api.github.com/repos/nunit/nunit/hooks","issue_events_url":"https://api.github.com/repos/nunit/nunit/issues/events{/number}","events_url":"https://api.github.com/repos/nunit/nunit/events","assignees_url":"https://api.github.com/repos/nunit/nunit/assignees{/user}","branches_url":"https://api.github.com/repos/nunit/nunit/branches{/branch}","tags_url":"https://api.github.com/repos/nunit/nunit/tags","blobs_url":"https://api.github.com/repos/nunit/nunit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nunit/nunit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nunit/nunit/git/refs{/sha}","trees_url":"https://api.github.com/repos/nunit/nunit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nunit/nunit/statuses/{sha}","languages_url":"https://api.github.com/repos/nunit/nunit/languages","stargazers_url":"https://api.github.com/repos/nunit/nunit/stargazers","contributors_url":"https://api.github.com/repos/nunit/nunit/contributors","subscribers_url":"https://api.github.com/repos/nunit/nunit/subscribers","subscription_url":"https://api.github.com/repos/nunit/nunit/subscription","commits_url":"https://api.github.com/repos/nunit/nunit/commits{/sha}","git_commits_url":"https://api.github.com/repos/nunit/nunit/git/commits{/sha}","comments_url":"https://api.github.com/repos/nunit/nunit/comments{/number}","issue_comment_url":"https://api.github.com/repos/nunit/nunit/issues/comments{/number}","contents_url":"https://api.github.com/repos/nunit/nunit/contents/{+path}","compare_url":"https://api.github.com/repos/nunit/nunit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nunit/nunit/merges","archive_url":"https://api.github.com/repos/nunit/nunit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nunit/nunit/downloads","issues_url":"https://api.github.com/repos/nunit/nunit/issues{/number}","pulls_url":"https://api.github.com/repos/nunit/nunit/pulls{/number}","milestones_url":"https://api.github.com/repos/nunit/nunit/milestones{/number}","notifications_url":"https://api.github.com/repos/nunit/nunit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nunit/nunit/labels{/name}","releases_url":"https://api.github.com/repos/nunit/nunit/releases{/id}","deployments_url":"https://api.github.com/repos/nunit/nunit/deployments","created_at":"2013-10-18T23:43:29Z","updated_at":"2016-04-25T07:39:35Z","pushed_at":"2016-04-25T23:44:44Z","git_url":"git://github.com/nunit/nunit.git","ssh_url":"git@github.com:nunit/nunit.git","clone_url":"https://github.com/nunit/nunit.git","svn_url":"https://github.com/nunit/nunit","homepage":"http://www.nunit.org/","size":36829,"stargazers_count":613,"watchers_count":613,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":240,"mirror_url":null,"open_issues_count":231,"forks":240,"open_issues":231,"watchers":613,"default_branch":"master"}},"base":{"label":"nunit:master","ref":"master","sha":"7a12faffe3e25ce25651234cea4b80229c854134","user":{"login":"nunit","id":2678858,"avatar_url":"https://avatars.githubusercontent.com/u/2678858?v=3","gravatar_id":"","url":"https://api.github.com/users/nunit","html_url":"https://github.com/nunit","followers_url":"https://api.github.com/users/nunit/followers","following_url":"https://api.github.com/users/nunit/following{/other_user}","gists_url":"https://api.github.com/users/nunit/gists{/gist_id}","starred_url":"https://api.github.com/users/nunit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nunit/subscriptions","organizations_url":"https://api.github.com/users/nunit/orgs","repos_url":"https://api.github.com/users/nunit/repos","events_url":"https://api.github.com/users/nunit/events{/privacy}","received_events_url":"https://api.github.com/users/nunit/received_events","type":"Organization","site_admin":false},"repo":{"id":13692183,"name":"nunit","full_name":"nunit/nunit","owner":{"login":"nunit","id":2678858,"avatar_url":"https://avatars.githubusercontent.com/u/2678858?v=3","gravatar_id":"","url":"https://api.github.com/users/nunit","html_url":"https://github.com/nunit","followers_url":"https://api.github.com/users/nunit/followers","following_url":"https://api.github.com/users/nunit/following{/other_user}","gists_url":"https://api.github.com/users/nunit/gists{/gist_id}","starred_url":"https://api.github.com/users/nunit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nunit/subscriptions","organizations_url":"https://api.github.com/users/nunit/orgs","repos_url":"https://api.github.com/users/nunit/repos","events_url":"https://api.github.com/users/nunit/events{/privacy}","received_events_url":"https://api.github.com/users/nunit/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nunit/nunit","description":"NUnit 3.0 framework, engine and console runner","fork":false,"url":"https://api.github.com/repos/nunit/nunit","forks_url":"https://api.github.com/repos/nunit/nunit/forks","keys_url":"https://api.github.com/repos/nunit/nunit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nunit/nunit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nunit/nunit/teams","hooks_url":"https://api.github.com/repos/nunit/nunit/hooks","issue_events_url":"https://api.github.com/repos/nunit/nunit/issues/events{/number}","events_url":"https://api.github.com/repos/nunit/nunit/events","assignees_url":"https://api.github.com/repos/nunit/nunit/assignees{/user}","branches_url":"https://api.github.com/repos/nunit/nunit/branches{/branch}","tags_url":"https://api.github.com/repos/nunit/nunit/tags","blobs_url":"https://api.github.com/repos/nunit/nunit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nunit/nunit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nunit/nunit/git/refs{/sha}","trees_url":"https://api.github.com/repos/nunit/nunit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nunit/nunit/statuses/{sha}","languages_url":"https://api.github.com/repos/nunit/nunit/languages","stargazers_url":"https://api.github.com/repos/nunit/nunit/stargazers","contributors_url":"https://api.github.com/repos/nunit/nunit/contributors","subscribers_url":"https://api.github.com/repos/nunit/nunit/subscribers","subscription_url":"https://api.github.com/repos/nunit/nunit/subscription","commits_url":"https://api.github.com/repos/nunit/nunit/commits{/sha}","git_commits_url":"https://api.github.com/repos/nunit/nunit/git/commits{/sha}","comments_url":"https://api.github.com/repos/nunit/nunit/comments{/number}","issue_comment_url":"https://api.github.com/repos/nunit/nunit/issues/comments{/number}","contents_url":"https://api.github.com/repos/nunit/nunit/contents/{+path}","compare_url":"https://api.github.com/repos/nunit/nunit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nunit/nunit/merges","archive_url":"https://api.github.com/repos/nunit/nunit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nunit/nunit/downloads","issues_url":"https://api.github.com/repos/nunit/nunit/issues{/number}","pulls_url":"https://api.github.com/repos/nunit/nunit/pulls{/number}","milestones_url":"https://api.github.com/repos/nunit/nunit/milestones{/number}","notifications_url":"https://api.github.com/repos/nunit/nunit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nunit/nunit/labels{/name}","releases_url":"https://api.github.com/repos/nunit/nunit/releases{/id}","deployments_url":"https://api.github.com/repos/nunit/nunit/deployments","created_at":"2013-10-18T23:43:29Z","updated_at":"2016-04-25T07:39:35Z","pushed_at":"2016-04-25T23:44:44Z","git_url":"git://github.com/nunit/nunit.git","ssh_url":"git@github.com:nunit/nunit.git","clone_url":"https://github.com/nunit/nunit.git","svn_url":"https://github.com/nunit/nunit","homepage":"http://www.nunit.org/","size":36829,"stargazers_count":613,"watchers_count":613,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":240,"mirror_url":null,"open_issues_count":231,"forks":240,"open_issues":231,"watchers":613,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nunit/nunit/pulls/1452"},"html":{"href":"https://github.com/nunit/nunit/pull/1452"},"issue":{"href":"https://api.github.com/repos/nunit/nunit/issues/1452"},"comments":{"href":"https://api.github.com/repos/nunit/nunit/issues/1452/comments"},"review_comments":{"href":"https://api.github.com/repos/nunit/nunit/pulls/1452/comments"},"review_comment":{"href":"https://api.github.com/repos/nunit/nunit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nunit/nunit/pulls/1452/commits"},"statuses":{"href":"https://api.github.com/repos/nunit/nunit/statuses/04ddbd2bc4c779c3d9576ac5ca95a31d8aca37dc"}}}}