{"action":"created","comment":{"url":"https://api.github.com/repos/nizshee/java-au/pulls/comments/78302264","id":78302264,"diff_hunk":"@@ -0,0 +1,56 @@\n+package com.github.nizshee;\n+\n+\n+import org.junit.Test;\n+\n+import java.util.concurrent.atomic.AtomicInteger;\n+import java.util.function.Supplier;\n+import java.util.stream.IntStream;\n+\n+import static org.junit.Assert.*;\n+\n+public class LazyFactoryTest {\n+\n+    @Test\n+    public void createLazySimpleTest() throws Exception {\n+        final AtomicInteger counter = new AtomicInteger(0);\n+        Supplier<String> supplier = () -> {\n+            int count = counter.incrementAndGet();\n+            return new String(new char[count]).replace(\"\\0\", \"a\");\n+        };\n+        Lazy<String> lazy = LazyFactory.createLazySimple(supplier);\n+\n+        IntStream.range(0, 4).forEach(i -> assertEquals(lazy.get(), \"a\"));\n+        assertEquals(1, counter.get());\n+    }\n+\n+    @Test\n+    public void createLazyConcurrentTest() throws Exception {\n+        IntStream.range(0, 4).forEach(i -> {\n+            final AtomicInteger counter = new AtomicInteger(0);\n+            Supplier<String> supplier = () -> {\n+                int count = counter.incrementAndGet();\n+                return new String(new char[count]).replace(\"\\0\", \"a\");\n+            };\n+            Lazy<String> lazy = LazyFactory.createLazyConcurent(supplier);\n+\n+            IntStream.range(0, 10000).parallel().forEach(j -> assertEquals(lazy.get(), \"a\"));\n+            assertEquals(counter.get(), 1);\n+        });\n+    }\n+\n+    @Test\n+    public void createLazyLockFreeTest() throws Exception {\n+        IntStream.range(0, 4).forEach(i -> {\n+            final AtomicInteger counter = new AtomicInteger(0);\n+            Supplier<String> supplier = () -> {\n+                int count = counter.incrementAndGet();\n+                return new String(new char[count]).replace(\"\\0\", \"a\");\n+            };\n+            Lazy<String> lazy = LazyFactory.createLazyLockFree(supplier);\n+\n+            IntStream.range(0, 10000).parallel().forEach(j -> assertEquals(lazy.get(), \"a\"));\n+            assertTrue(counter.get() > 0);\n+        });\n+    }","path":"src/test/java/com/github/nizshee/LazyFactoryTest.java","position":55,"original_position":55,"commit_id":"0846099c166700e8c4a2e0b80f5592caf1dff7ae","original_commit_id":"0846099c166700e8c4a2e0b80f5592caf1dff7ae","user":{"login":"sproshev","id":4990763,"avatar_url":"https://avatars.githubusercontent.com/u/4990763?v=3","gravatar_id":"","url":"https://api.github.com/users/sproshev","html_url":"https://github.com/sproshev","followers_url":"https://api.github.com/users/sproshev/followers","following_url":"https://api.github.com/users/sproshev/following{/other_user}","gists_url":"https://api.github.com/users/sproshev/gists{/gist_id}","starred_url":"https://api.github.com/users/sproshev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sproshev/subscriptions","organizations_url":"https://api.github.com/users/sproshev/orgs","repos_url":"https://api.github.com/users/sproshev/repos","events_url":"https://api.github.com/users/sproshev/events{/privacy}","received_events_url":"https://api.github.com/users/sproshev/received_events","type":"User","site_admin":false},"body":"аналогично\r\nно еще не проверяется, что для каждого потока вычисление не больше 1 раза запускалось","created_at":"2016-09-11T20:51:36Z","updated_at":"2016-09-11T20:51:36Z","html_url":"https://github.com/nizshee/java-au/pull/6#discussion_r78302264","pull_request_url":"https://api.github.com/repos/nizshee/java-au/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/nizshee/java-au/pulls/comments/78302264"},"html":{"href":"https://github.com/nizshee/java-au/pull/6#discussion_r78302264"},"pull_request":{"href":"https://api.github.com/repos/nizshee/java-au/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/nizshee/java-au/pulls/6","id":84784256,"html_url":"https://github.com/nizshee/java-au/pull/6","diff_url":"https://github.com/nizshee/java-au/pull/6.diff","patch_url":"https://github.com/nizshee/java-au/pull/6.patch","issue_url":"https://api.github.com/repos/nizshee/java-au/issues/6","number":6,"state":"open","locked":false,"title":"Java02. ДЗ 01, Васильев Роман","user":{"login":"nizshee","id":8837119,"avatar_url":"https://avatars.githubusercontent.com/u/8837119?v=3","gravatar_id":"","url":"https://api.github.com/users/nizshee","html_url":"https://github.com/nizshee","followers_url":"https://api.github.com/users/nizshee/followers","following_url":"https://api.github.com/users/nizshee/following{/other_user}","gists_url":"https://api.github.com/users/nizshee/gists{/gist_id}","starred_url":"https://api.github.com/users/nizshee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nizshee/subscriptions","organizations_url":"https://api.github.com/users/nizshee/orgs","repos_url":"https://api.github.com/users/nizshee/repos","events_url":"https://api.github.com/users/nizshee/events{/privacy}","received_events_url":"https://api.github.com/users/nizshee/received_events","type":"User","site_admin":false},"body":"@sproshev","created_at":"2016-09-11T11:46:54Z","updated_at":"2016-09-11T20:51:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d6fb541b593f6b7bac81609b6e6c7519f0d1af1a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/nizshee/java-au/pulls/6/commits","review_comments_url":"https://api.github.com/repos/nizshee/java-au/pulls/6/comments","review_comment_url":"https://api.github.com/repos/nizshee/java-au/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nizshee/java-au/issues/6/comments","statuses_url":"https://api.github.com/repos/nizshee/java-au/statuses/0846099c166700e8c4a2e0b80f5592caf1dff7ae","head":{"label":"nizshee:task11","ref":"task11","sha":"0846099c166700e8c4a2e0b80f5592caf1dff7ae","user":{"login":"nizshee","id":8837119,"avatar_url":"https://avatars.githubusercontent.com/u/8837119?v=3","gravatar_id":"","url":"https://api.github.com/users/nizshee","html_url":"https://github.com/nizshee","followers_url":"https://api.github.com/users/nizshee/followers","following_url":"https://api.github.com/users/nizshee/following{/other_user}","gists_url":"https://api.github.com/users/nizshee/gists{/gist_id}","starred_url":"https://api.github.com/users/nizshee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nizshee/subscriptions","organizations_url":"https://api.github.com/users/nizshee/orgs","repos_url":"https://api.github.com/users/nizshee/repos","events_url":"https://api.github.com/users/nizshee/events{/privacy}","received_events_url":"https://api.github.com/users/nizshee/received_events","type":"User","site_admin":false},"repo":{"id":52625582,"name":"java-au","full_name":"nizshee/java-au","owner":{"login":"nizshee","id":8837119,"avatar_url":"https://avatars.githubusercontent.com/u/8837119?v=3","gravatar_id":"","url":"https://api.github.com/users/nizshee","html_url":"https://github.com/nizshee","followers_url":"https://api.github.com/users/nizshee/followers","following_url":"https://api.github.com/users/nizshee/following{/other_user}","gists_url":"https://api.github.com/users/nizshee/gists{/gist_id}","starred_url":"https://api.github.com/users/nizshee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nizshee/subscriptions","organizations_url":"https://api.github.com/users/nizshee/orgs","repos_url":"https://api.github.com/users/nizshee/repos","events_url":"https://api.github.com/users/nizshee/events{/privacy}","received_events_url":"https://api.github.com/users/nizshee/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nizshee/java-au","description":"","fork":false,"url":"https://api.github.com/repos/nizshee/java-au","forks_url":"https://api.github.com/repos/nizshee/java-au/forks","keys_url":"https://api.github.com/repos/nizshee/java-au/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nizshee/java-au/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nizshee/java-au/teams","hooks_url":"https://api.github.com/repos/nizshee/java-au/hooks","issue_events_url":"https://api.github.com/repos/nizshee/java-au/issues/events{/number}","events_url":"https://api.github.com/repos/nizshee/java-au/events","assignees_url":"https://api.github.com/repos/nizshee/java-au/assignees{/user}","branches_url":"https://api.github.com/repos/nizshee/java-au/branches{/branch}","tags_url":"https://api.github.com/repos/nizshee/java-au/tags","blobs_url":"https://api.github.com/repos/nizshee/java-au/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nizshee/java-au/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nizshee/java-au/git/refs{/sha}","trees_url":"https://api.github.com/repos/nizshee/java-au/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nizshee/java-au/statuses/{sha}","languages_url":"https://api.github.com/repos/nizshee/java-au/languages","stargazers_url":"https://api.github.com/repos/nizshee/java-au/stargazers","contributors_url":"https://api.github.com/repos/nizshee/java-au/contributors","subscribers_url":"https://api.github.com/repos/nizshee/java-au/subscribers","subscription_url":"https://api.github.com/repos/nizshee/java-au/subscription","commits_url":"https://api.github.com/repos/nizshee/java-au/commits{/sha}","git_commits_url":"https://api.github.com/repos/nizshee/java-au/git/commits{/sha}","comments_url":"https://api.github.com/repos/nizshee/java-au/comments{/number}","issue_comment_url":"https://api.github.com/repos/nizshee/java-au/issues/comments{/number}","contents_url":"https://api.github.com/repos/nizshee/java-au/contents/{+path}","compare_url":"https://api.github.com/repos/nizshee/java-au/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nizshee/java-au/merges","archive_url":"https://api.github.com/repos/nizshee/java-au/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nizshee/java-au/downloads","issues_url":"https://api.github.com/repos/nizshee/java-au/issues{/number}","pulls_url":"https://api.github.com/repos/nizshee/java-au/pulls{/number}","milestones_url":"https://api.github.com/repos/nizshee/java-au/milestones{/number}","notifications_url":"https://api.github.com/repos/nizshee/java-au/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nizshee/java-au/labels{/name}","releases_url":"https://api.github.com/repos/nizshee/java-au/releases{/id}","deployments_url":"https://api.github.com/repos/nizshee/java-au/deployments","created_at":"2016-02-26T18:52:50Z","updated_at":"2016-09-11T10:58:03Z","pushed_at":"2016-09-11T11:46:54Z","git_url":"git://github.com/nizshee/java-au.git","ssh_url":"git@github.com:nizshee/java-au.git","clone_url":"https://github.com/nizshee/java-au.git","svn_url":"https://github.com/nizshee/java-au","homepage":null,"size":43,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":6,"forks":0,"open_issues":6,"watchers":0,"default_branch":"master"}},"base":{"label":"nizshee:master","ref":"master","sha":"2bdf499196bece4ba35db244e5bfd90db3bd41ca","user":{"login":"nizshee","id":8837119,"avatar_url":"https://avatars.githubusercontent.com/u/8837119?v=3","gravatar_id":"","url":"https://api.github.com/users/nizshee","html_url":"https://github.com/nizshee","followers_url":"https://api.github.com/users/nizshee/followers","following_url":"https://api.github.com/users/nizshee/following{/other_user}","gists_url":"https://api.github.com/users/nizshee/gists{/gist_id}","starred_url":"https://api.github.com/users/nizshee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nizshee/subscriptions","organizations_url":"https://api.github.com/users/nizshee/orgs","repos_url":"https://api.github.com/users/nizshee/repos","events_url":"https://api.github.com/users/nizshee/events{/privacy}","received_events_url":"https://api.github.com/users/nizshee/received_events","type":"User","site_admin":false},"repo":{"id":52625582,"name":"java-au","full_name":"nizshee/java-au","owner":{"login":"nizshee","id":8837119,"avatar_url":"https://avatars.githubusercontent.com/u/8837119?v=3","gravatar_id":"","url":"https://api.github.com/users/nizshee","html_url":"https://github.com/nizshee","followers_url":"https://api.github.com/users/nizshee/followers","following_url":"https://api.github.com/users/nizshee/following{/other_user}","gists_url":"https://api.github.com/users/nizshee/gists{/gist_id}","starred_url":"https://api.github.com/users/nizshee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nizshee/subscriptions","organizations_url":"https://api.github.com/users/nizshee/orgs","repos_url":"https://api.github.com/users/nizshee/repos","events_url":"https://api.github.com/users/nizshee/events{/privacy}","received_events_url":"https://api.github.com/users/nizshee/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nizshee/java-au","description":"","fork":false,"url":"https://api.github.com/repos/nizshee/java-au","forks_url":"https://api.github.com/repos/nizshee/java-au/forks","keys_url":"https://api.github.com/repos/nizshee/java-au/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nizshee/java-au/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nizshee/java-au/teams","hooks_url":"https://api.github.com/repos/nizshee/java-au/hooks","issue_events_url":"https://api.github.com/repos/nizshee/java-au/issues/events{/number}","events_url":"https://api.github.com/repos/nizshee/java-au/events","assignees_url":"https://api.github.com/repos/nizshee/java-au/assignees{/user}","branches_url":"https://api.github.com/repos/nizshee/java-au/branches{/branch}","tags_url":"https://api.github.com/repos/nizshee/java-au/tags","blobs_url":"https://api.github.com/repos/nizshee/java-au/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nizshee/java-au/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nizshee/java-au/git/refs{/sha}","trees_url":"https://api.github.com/repos/nizshee/java-au/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nizshee/java-au/statuses/{sha}","languages_url":"https://api.github.com/repos/nizshee/java-au/languages","stargazers_url":"https://api.github.com/repos/nizshee/java-au/stargazers","contributors_url":"https://api.github.com/repos/nizshee/java-au/contributors","subscribers_url":"https://api.github.com/repos/nizshee/java-au/subscribers","subscription_url":"https://api.github.com/repos/nizshee/java-au/subscription","commits_url":"https://api.github.com/repos/nizshee/java-au/commits{/sha}","git_commits_url":"https://api.github.com/repos/nizshee/java-au/git/commits{/sha}","comments_url":"https://api.github.com/repos/nizshee/java-au/comments{/number}","issue_comment_url":"https://api.github.com/repos/nizshee/java-au/issues/comments{/number}","contents_url":"https://api.github.com/repos/nizshee/java-au/contents/{+path}","compare_url":"https://api.github.com/repos/nizshee/java-au/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nizshee/java-au/merges","archive_url":"https://api.github.com/repos/nizshee/java-au/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nizshee/java-au/downloads","issues_url":"https://api.github.com/repos/nizshee/java-au/issues{/number}","pulls_url":"https://api.github.com/repos/nizshee/java-au/pulls{/number}","milestones_url":"https://api.github.com/repos/nizshee/java-au/milestones{/number}","notifications_url":"https://api.github.com/repos/nizshee/java-au/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nizshee/java-au/labels{/name}","releases_url":"https://api.github.com/repos/nizshee/java-au/releases{/id}","deployments_url":"https://api.github.com/repos/nizshee/java-au/deployments","created_at":"2016-02-26T18:52:50Z","updated_at":"2016-09-11T10:58:03Z","pushed_at":"2016-09-11T11:46:54Z","git_url":"git://github.com/nizshee/java-au.git","ssh_url":"git@github.com:nizshee/java-au.git","clone_url":"https://github.com/nizshee/java-au.git","svn_url":"https://github.com/nizshee/java-au","homepage":null,"size":43,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":6,"forks":0,"open_issues":6,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nizshee/java-au/pulls/6"},"html":{"href":"https://github.com/nizshee/java-au/pull/6"},"issue":{"href":"https://api.github.com/repos/nizshee/java-au/issues/6"},"comments":{"href":"https://api.github.com/repos/nizshee/java-au/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/nizshee/java-au/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/nizshee/java-au/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nizshee/java-au/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/nizshee/java-au/statuses/0846099c166700e8c4a2e0b80f5592caf1dff7ae"}}}}
{"actor":{"display_login":"sproshev"}}