{"action":"created","comment":{"url":"https://api.github.com/repos/cookpad/Puree-Swift/pulls/comments/207193628","pull_request_review_id":142753105,"id":207193628,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNzE5MzYyOA==","diff_hunk":"@@ -136,10 +142,84 @@ class BufferedOutputTests: XCTestCase {\n         XCTAssertEqual(output.calledWriteCount, 4)\n     }\n \n+    func testParallelWrite() {\n+        output.configuration.logEntryCountLimit = 3\n+        output.configuration.retryLimit = 3\n+\n+        XCTAssertEqual(logStore.logs(for: \"pv_TestingBufferedOutput\").count, 0)\n+        XCTAssertEqual(output.calledWriteCount, 0)\n+\n+        var writeCallbackCalledCount = 0\n+        output.writeCallback = {\n+            writeCallbackCalledCount += 1\n+        }\n+\n+        let semaphore = DispatchSemaphore(value: 0)\n+        let testIndices = 0..<200\n+\n+        for _ in testIndices {\n+            DispatchQueue.global(qos: .background).async {\n+                self.output.emit(log: self.makeLog())\n+                semaphore.signal()\n+            }\n+        }\n+\n+        for _ in testIndices {\n+            semaphore.wait()\n+        }\n+        output.resume()\n+\n+        let expectedWriteCount = 67\n+        XCTAssertEqual(output.calledWriteCount, expectedWriteCount)\n+        XCTAssertEqual(writeCallbackCalledCount, expectedWriteCount)\n+    }\n+\n     override func tearDown() {\n         super.tearDown()\n \n         output.suspend()\n         logStore.flush()\n     }\n }\n+\n+class TestingBufferedOutputAsync: TestingBufferedOutput {\n+    private var expectations: [XCTestExpectation] = []\n+    var testCase: XCTestCase!","path":"Tests/PureeTests/Output/BufferedOutputTests.swift","position":96,"original_position":96,"commit_id":"e6e93d78111288dc9ca3265bcceb6db070bebec8","original_commit_id":"e6e93d78111288dc9ca3265bcceb6db070bebec8","user":{"login":"giginet","id":147051,"node_id":"MDQ6VXNlcjE0NzA1MQ==","avatar_url":"https://avatars3.githubusercontent.com/u/147051?v=4","gravatar_id":"","url":"https://api.github.com/users/giginet","html_url":"https://github.com/giginet","followers_url":"https://api.github.com/users/giginet/followers","following_url":"https://api.github.com/users/giginet/following{/other_user}","gists_url":"https://api.github.com/users/giginet/gists{/gist_id}","starred_url":"https://api.github.com/users/giginet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giginet/subscriptions","organizations_url":"https://api.github.com/users/giginet/orgs","repos_url":"https://api.github.com/users/giginet/repos","events_url":"https://api.github.com/users/giginet/events{/privacy}","received_events_url":"https://api.github.com/users/giginet/received_events","type":"User","site_admin":false},"body":"It caused circular reference.","created_at":"2018-08-02T11:36:09Z","updated_at":"2018-08-02T11:37:28Z","html_url":"https://github.com/cookpad/Puree-Swift/pull/11#discussion_r207193628","pull_request_url":"https://api.github.com/repos/cookpad/Puree-Swift/pulls/11","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/cookpad/Puree-Swift/pulls/comments/207193628"},"html":{"href":"https://github.com/cookpad/Puree-Swift/pull/11#discussion_r207193628"},"pull_request":{"href":"https://api.github.com/repos/cookpad/Puree-Swift/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/cookpad/Puree-Swift/pulls/11","id":202518104,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAyNTE4MTA0","html_url":"https://github.com/cookpad/Puree-Swift/pull/11","diff_url":"https://github.com/cookpad/Puree-Swift/pull/11.diff","patch_url":"https://github.com/cookpad/Puree-Swift/pull/11.patch","issue_url":"https://api.github.com/repos/cookpad/Puree-Swift/issues/11","number":11,"state":"open","locked":false,"title":"Logger works in sub thread and make buffered output thread safety","user":{"login":"sidepelican","id":19257572,"node_id":"MDQ6VXNlcjE5MjU3NTcy","avatar_url":"https://avatars2.githubusercontent.com/u/19257572?v=4","gravatar_id":"","url":"https://api.github.com/users/sidepelican","html_url":"https://github.com/sidepelican","followers_url":"https://api.github.com/users/sidepelican/followers","following_url":"https://api.github.com/users/sidepelican/following{/other_user}","gists_url":"https://api.github.com/users/sidepelican/gists{/gist_id}","starred_url":"https://api.github.com/users/sidepelican/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sidepelican/subscriptions","organizations_url":"https://api.github.com/users/sidepelican/orgs","repos_url":"https://api.github.com/users/sidepelican/repos","events_url":"https://api.github.com/users/sidepelican/events{/privacy}","received_events_url":"https://api.github.com/users/sidepelican/received_events","type":"User","site_admin":false},"body":"I think the logger should work in sub thread for the good UI performance.\r\nNow the logger is not thread safe so it must called in the same thread. In general, it may be the main thread. `FileLogStore` uses disk IO so it blocks the main thread long time.\r\n\r\nI made the `Logger` works in its own DispatchQueue, `BufferedOutput` get thread safe and access to the logStore in the same DispatchQueue.","created_at":"2018-07-19T10:43:09Z","updated_at":"2018-08-02T11:37:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2148248ef85c2572b8d4b8452bfbeb92a0156640","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/cookpad/Puree-Swift/pulls/11/commits","review_comments_url":"https://api.github.com/repos/cookpad/Puree-Swift/pulls/11/comments","review_comment_url":"https://api.github.com/repos/cookpad/Puree-Swift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cookpad/Puree-Swift/issues/11/comments","statuses_url":"https://api.github.com/repos/cookpad/Puree-Swift/statuses/e6e93d78111288dc9ca3265bcceb6db070bebec8","head":{"label":"sidepelican:feature/bg_thread","ref":"feature/bg_thread","sha":"e6e93d78111288dc9ca3265bcceb6db070bebec8","user":{"login":"sidepelican","id":19257572,"node_id":"MDQ6VXNlcjE5MjU3NTcy","avatar_url":"https://avatars2.githubusercontent.com/u/19257572?v=4","gravatar_id":"","url":"https://api.github.com/users/sidepelican","html_url":"https://github.com/sidepelican","followers_url":"https://api.github.com/users/sidepelican/followers","following_url":"https://api.github.com/users/sidepelican/following{/other_user}","gists_url":"https://api.github.com/users/sidepelican/gists{/gist_id}","starred_url":"https://api.github.com/users/sidepelican/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sidepelican/subscriptions","organizations_url":"https://api.github.com/users/sidepelican/orgs","repos_url":"https://api.github.com/users/sidepelican/repos","events_url":"https://api.github.com/users/sidepelican/events{/privacy}","received_events_url":"https://api.github.com/users/sidepelican/received_events","type":"User","site_admin":false},"repo":{"id":140800744,"node_id":"MDEwOlJlcG9zaXRvcnkxNDA4MDA3NDQ=","name":"Puree-Swift","full_name":"sidepelican/Puree-Swift","owner":{"login":"sidepelican","id":19257572,"node_id":"MDQ6VXNlcjE5MjU3NTcy","avatar_url":"https://avatars2.githubusercontent.com/u/19257572?v=4","gravatar_id":"","url":"https://api.github.com/users/sidepelican","html_url":"https://github.com/sidepelican","followers_url":"https://api.github.com/users/sidepelican/followers","following_url":"https://api.github.com/users/sidepelican/following{/other_user}","gists_url":"https://api.github.com/users/sidepelican/gists{/gist_id}","starred_url":"https://api.github.com/users/sidepelican/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sidepelican/subscriptions","organizations_url":"https://api.github.com/users/sidepelican/orgs","repos_url":"https://api.github.com/users/sidepelican/repos","events_url":"https://api.github.com/users/sidepelican/events{/privacy}","received_events_url":"https://api.github.com/users/sidepelican/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sidepelican/Puree-Swift","description":"Awesome log aggregator for iOS","fork":true,"url":"https://api.github.com/repos/sidepelican/Puree-Swift","forks_url":"https://api.github.com/repos/sidepelican/Puree-Swift/forks","keys_url":"https://api.github.com/repos/sidepelican/Puree-Swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sidepelican/Puree-Swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sidepelican/Puree-Swift/teams","hooks_url":"https://api.github.com/repos/sidepelican/Puree-Swift/hooks","issue_events_url":"https://api.github.com/repos/sidepelican/Puree-Swift/issues/events{/number}","events_url":"https://api.github.com/repos/sidepelican/Puree-Swift/events","assignees_url":"https://api.github.com/repos/sidepelican/Puree-Swift/assignees{/user}","branches_url":"https://api.github.com/repos/sidepelican/Puree-Swift/branches{/branch}","tags_url":"https://api.github.com/repos/sidepelican/Puree-Swift/tags","blobs_url":"https://api.github.com/repos/sidepelican/Puree-Swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sidepelican/Puree-Swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sidepelican/Puree-Swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/sidepelican/Puree-Swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sidepelican/Puree-Swift/statuses/{sha}","languages_url":"https://api.github.com/repos/sidepelican/Puree-Swift/languages","stargazers_url":"https://api.github.com/repos/sidepelican/Puree-Swift/stargazers","contributors_url":"https://api.github.com/repos/sidepelican/Puree-Swift/contributors","subscribers_url":"https://api.github.com/repos/sidepelican/Puree-Swift/subscribers","subscription_url":"https://api.github.com/repos/sidepelican/Puree-Swift/subscription","commits_url":"https://api.github.com/repos/sidepelican/Puree-Swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/sidepelican/Puree-Swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/sidepelican/Puree-Swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/sidepelican/Puree-Swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/sidepelican/Puree-Swift/contents/{+path}","compare_url":"https://api.github.com/repos/sidepelican/Puree-Swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sidepelican/Puree-Swift/merges","archive_url":"https://api.github.com/repos/sidepelican/Puree-Swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sidepelican/Puree-Swift/downloads","issues_url":"https://api.github.com/repos/sidepelican/Puree-Swift/issues{/number}","pulls_url":"https://api.github.com/repos/sidepelican/Puree-Swift/pulls{/number}","milestones_url":"https://api.github.com/repos/sidepelican/Puree-Swift/milestones{/number}","notifications_url":"https://api.github.com/repos/sidepelican/Puree-Swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sidepelican/Puree-Swift/labels{/name}","releases_url":"https://api.github.com/repos/sidepelican/Puree-Swift/releases{/id}","deployments_url":"https://api.github.com/repos/sidepelican/Puree-Swift/deployments","created_at":"2018-07-13T05:24:42Z","updated_at":"2018-07-13T05:24:44Z","pushed_at":"2018-08-02T10:43:05Z","git_url":"git://github.com/sidepelican/Puree-Swift.git","ssh_url":"git@github.com:sidepelican/Puree-Swift.git","clone_url":"https://github.com/sidepelican/Puree-Swift.git","svn_url":"https://github.com/sidepelican/Puree-Swift","homepage":"","size":188,"stargazers_count":0,"watchers_count":0,"language":"Swift","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":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cookpad:4.0.0-beta","ref":"4.0.0-beta","sha":"bc75fa136c68c1413e98e27290ee774708af46d9","user":{"login":"cookpad","id":119195,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExOTE5NQ==","avatar_url":"https://avatars1.githubusercontent.com/u/119195?v=4","gravatar_id":"","url":"https://api.github.com/users/cookpad","html_url":"https://github.com/cookpad","followers_url":"https://api.github.com/users/cookpad/followers","following_url":"https://api.github.com/users/cookpad/following{/other_user}","gists_url":"https://api.github.com/users/cookpad/gists{/gist_id}","starred_url":"https://api.github.com/users/cookpad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cookpad/subscriptions","organizations_url":"https://api.github.com/users/cookpad/orgs","repos_url":"https://api.github.com/users/cookpad/repos","events_url":"https://api.github.com/users/cookpad/events{/privacy}","received_events_url":"https://api.github.com/users/cookpad/received_events","type":"Organization","site_admin":false},"repo":{"id":120869522,"node_id":"MDEwOlJlcG9zaXRvcnkxMjA4Njk1MjI=","name":"Puree-Swift","full_name":"cookpad/Puree-Swift","owner":{"login":"cookpad","id":119195,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExOTE5NQ==","avatar_url":"https://avatars1.githubusercontent.com/u/119195?v=4","gravatar_id":"","url":"https://api.github.com/users/cookpad","html_url":"https://github.com/cookpad","followers_url":"https://api.github.com/users/cookpad/followers","following_url":"https://api.github.com/users/cookpad/following{/other_user}","gists_url":"https://api.github.com/users/cookpad/gists{/gist_id}","starred_url":"https://api.github.com/users/cookpad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cookpad/subscriptions","organizations_url":"https://api.github.com/users/cookpad/orgs","repos_url":"https://api.github.com/users/cookpad/repos","events_url":"https://api.github.com/users/cookpad/events{/privacy}","received_events_url":"https://api.github.com/users/cookpad/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cookpad/Puree-Swift","description":"Awesome log aggregator for iOS","fork":false,"url":"https://api.github.com/repos/cookpad/Puree-Swift","forks_url":"https://api.github.com/repos/cookpad/Puree-Swift/forks","keys_url":"https://api.github.com/repos/cookpad/Puree-Swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cookpad/Puree-Swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cookpad/Puree-Swift/teams","hooks_url":"https://api.github.com/repos/cookpad/Puree-Swift/hooks","issue_events_url":"https://api.github.com/repos/cookpad/Puree-Swift/issues/events{/number}","events_url":"https://api.github.com/repos/cookpad/Puree-Swift/events","assignees_url":"https://api.github.com/repos/cookpad/Puree-Swift/assignees{/user}","branches_url":"https://api.github.com/repos/cookpad/Puree-Swift/branches{/branch}","tags_url":"https://api.github.com/repos/cookpad/Puree-Swift/tags","blobs_url":"https://api.github.com/repos/cookpad/Puree-Swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cookpad/Puree-Swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cookpad/Puree-Swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/cookpad/Puree-Swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cookpad/Puree-Swift/statuses/{sha}","languages_url":"https://api.github.com/repos/cookpad/Puree-Swift/languages","stargazers_url":"https://api.github.com/repos/cookpad/Puree-Swift/stargazers","contributors_url":"https://api.github.com/repos/cookpad/Puree-Swift/contributors","subscribers_url":"https://api.github.com/repos/cookpad/Puree-Swift/subscribers","subscription_url":"https://api.github.com/repos/cookpad/Puree-Swift/subscription","commits_url":"https://api.github.com/repos/cookpad/Puree-Swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/cookpad/Puree-Swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/cookpad/Puree-Swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/cookpad/Puree-Swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/cookpad/Puree-Swift/contents/{+path}","compare_url":"https://api.github.com/repos/cookpad/Puree-Swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cookpad/Puree-Swift/merges","archive_url":"https://api.github.com/repos/cookpad/Puree-Swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cookpad/Puree-Swift/downloads","issues_url":"https://api.github.com/repos/cookpad/Puree-Swift/issues{/number}","pulls_url":"https://api.github.com/repos/cookpad/Puree-Swift/pulls{/number}","milestones_url":"https://api.github.com/repos/cookpad/Puree-Swift/milestones{/number}","notifications_url":"https://api.github.com/repos/cookpad/Puree-Swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cookpad/Puree-Swift/labels{/name}","releases_url":"https://api.github.com/repos/cookpad/Puree-Swift/releases{/id}","deployments_url":"https://api.github.com/repos/cookpad/Puree-Swift/deployments","created_at":"2018-02-09T06:58:17Z","updated_at":"2018-07-30T16:58:06Z","pushed_at":"2018-08-02T10:43:07Z","git_url":"git://github.com/cookpad/Puree-Swift.git","ssh_url":"git@github.com:cookpad/Puree-Swift.git","clone_url":"https://github.com/cookpad/Puree-Swift.git","svn_url":"https://github.com/cookpad/Puree-Swift","homepage":"","size":177,"stargazers_count":113,"watchers_count":113,"language":"Swift","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":7,"open_issues":2,"watchers":113,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cookpad/Puree-Swift/pulls/11"},"html":{"href":"https://github.com/cookpad/Puree-Swift/pull/11"},"issue":{"href":"https://api.github.com/repos/cookpad/Puree-Swift/issues/11"},"comments":{"href":"https://api.github.com/repos/cookpad/Puree-Swift/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/cookpad/Puree-Swift/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/cookpad/Puree-Swift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cookpad/Puree-Swift/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/cookpad/Puree-Swift/statuses/e6e93d78111288dc9ca3265bcceb6db070bebec8"}},"author_association":"NONE"}}
{"actor":{"display_login":"giginet"}}