{"action":"created","comment":{"url":"https://api.github.com/repos/cscenter/hpcourse/pulls/comments/175866737","pull_request_review_id":105469175,"id":175866737,"diff_hunk":"@@ -0,0 +1,133 @@\n+#include <cstdlib>\n+#include <iostream>\n+#include <pthread.h>\n+#include <list>\n+#include <vector>\n+\n+pthread_t producer;\n+pthread_t consumer;\n+pthread_t interrupter;  \n+\n+pthread_mutex_t       mutex = PTHREAD_MUTEX_INITIALIZER;\n+// notify that producer complete a part of work \n+pthread_cond_t producer_signal = PTHREAD_COND_INITIALIZER;\n+// notify that consumer complete a processing a nunber \n+pthread_cond_t consumer_complete_processing = PTHREAD_COND_INITIALIZER;\n+pthread_cond_t consumer_started = PTHREAD_COND_INITIALIZER;\n+\n+int data = 0;\n+\n+bool consumer_should_work = false;\n+bool all_is_done = false;\n+bool consumer_started_flag = false;\n+\n+void *producer_routine(void* args) {\n+    \n+    std::list<int>* elements = (std::list<int>*) args;\n+    std::list<int>::iterator it;\n+  \n+    pthread_mutex_lock(&mutex);\n+    for (it = elements->begin(); it != elements->end(); ++it) {\n+        data = *it;\n+        consumer_should_work = true;\n+     \n+        // put new data\n+        pthread_cond_signal(&producer_signal);\n+        \n+        // wait until consumer complete processing\n+        while (consumer_should_work) {\n+            pthread_cond_wait(&consumer_complete_processing, &mutex);\n+        }\n+    }\n+    \n+    // need to call that consumer should work and all data were pushed\n+    consumer_should_work = true;\n+    all_is_done = true;\n+    pthread_cond_signal(&producer_signal);\n+    pthread_mutex_unlock(&mutex);\n+    \n+    pthread_exit(NULL);\n+}\n+\n+void *consumer_routine(void* args) {\n+    // protect for cancelling\n+    pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);\n+    \n+    // notify that consumer started\n+    pthread_mutex_lock(&mutex);\n+    consumer_started_flag = true;\n+    pthread_cond_signal(&consumer_started);\n+    int* sum = (int*) args;\n+    while(true) {\n+        // waith for signal from producer\n+        while (!consumer_should_work) {\n+            pthread_cond_wait(&producer_signal, &mutex);\n+        }\n+       \n+        // if all_is_done we should exit\n+        if (all_is_done) {\n+            pthread_mutex_unlock(&mutex);\n+            pthread_exit((void *) sum);","path":"csc/2018/1.Pthread/BezguzikovAV/main.cpp","position":70,"original_position":70,"commit_id":"b0282f202fcafcde0fe2e25d8d4e90b670eaacaa","original_commit_id":"b0282f202fcafcde0fe2e25d8d4e90b670eaacaa","user":{"login":"EduardovEduard","id":698985,"avatar_url":"https://avatars0.githubusercontent.com/u/698985?v=4","gravatar_id":"","url":"https://api.github.com/users/EduardovEduard","html_url":"https://github.com/EduardovEduard","followers_url":"https://api.github.com/users/EduardovEduard/followers","following_url":"https://api.github.com/users/EduardovEduard/following{/other_user}","gists_url":"https://api.github.com/users/EduardovEduard/gists{/gist_id}","starred_url":"https://api.github.com/users/EduardovEduard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EduardovEduard/subscriptions","organizations_url":"https://api.github.com/users/EduardovEduard/orgs","repos_url":"https://api.github.com/users/EduardovEduard/repos","events_url":"https://api.github.com/users/EduardovEduard/events{/privacy}","received_events_url":"https://api.github.com/users/EduardovEduard/received_events","type":"User","site_admin":false},"body":"Возвращаемое значение не используется в `run_threads`","created_at":"2018-03-20T17:57:37Z","updated_at":"2018-03-20T17:57:38Z","html_url":"https://github.com/cscenter/hpcourse/pull/196#discussion_r175866737","pull_request_url":"https://api.github.com/repos/cscenter/hpcourse/pulls/196","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/cscenter/hpcourse/pulls/comments/175866737"},"html":{"href":"https://github.com/cscenter/hpcourse/pull/196#discussion_r175866737"},"pull_request":{"href":"https://api.github.com/repos/cscenter/hpcourse/pulls/196"}}},"pull_request":{"url":"https://api.github.com/repos/cscenter/hpcourse/pulls/196","id":175749934,"html_url":"https://github.com/cscenter/hpcourse/pull/196","diff_url":"https://github.com/cscenter/hpcourse/pull/196.diff","patch_url":"https://github.com/cscenter/hpcourse/pull/196.patch","issue_url":"https://api.github.com/repos/cscenter/hpcourse/issues/196","number":196,"state":"open","locked":false,"title":"HW1 BezguzikovAV","user":{"login":"artbez","id":6135618,"avatar_url":"https://avatars1.githubusercontent.com/u/6135618?v=4","gravatar_id":"","url":"https://api.github.com/users/artbez","html_url":"https://github.com/artbez","followers_url":"https://api.github.com/users/artbez/followers","following_url":"https://api.github.com/users/artbez/following{/other_user}","gists_url":"https://api.github.com/users/artbez/gists{/gist_id}","starred_url":"https://api.github.com/users/artbez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artbez/subscriptions","organizations_url":"https://api.github.com/users/artbez/orgs","repos_url":"https://api.github.com/users/artbez/repos","events_url":"https://api.github.com/users/artbez/events{/privacy}","received_events_url":"https://api.github.com/users/artbez/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-03-18T13:00:01Z","updated_at":"2018-03-20T17:57:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"be24e36e9b5025502009a7f00ac68602f89a0881","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/cscenter/hpcourse/pulls/196/commits","review_comments_url":"https://api.github.com/repos/cscenter/hpcourse/pulls/196/comments","review_comment_url":"https://api.github.com/repos/cscenter/hpcourse/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cscenter/hpcourse/issues/196/comments","statuses_url":"https://api.github.com/repos/cscenter/hpcourse/statuses/b0282f202fcafcde0fe2e25d8d4e90b670eaacaa","head":{"label":"artbez:master","ref":"master","sha":"b0282f202fcafcde0fe2e25d8d4e90b670eaacaa","user":{"login":"artbez","id":6135618,"avatar_url":"https://avatars1.githubusercontent.com/u/6135618?v=4","gravatar_id":"","url":"https://api.github.com/users/artbez","html_url":"https://github.com/artbez","followers_url":"https://api.github.com/users/artbez/followers","following_url":"https://api.github.com/users/artbez/following{/other_user}","gists_url":"https://api.github.com/users/artbez/gists{/gist_id}","starred_url":"https://api.github.com/users/artbez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artbez/subscriptions","organizations_url":"https://api.github.com/users/artbez/orgs","repos_url":"https://api.github.com/users/artbez/repos","events_url":"https://api.github.com/users/artbez/events{/privacy}","received_events_url":"https://api.github.com/users/artbez/received_events","type":"User","site_admin":false},"repo":{"id":125724523,"name":"hpcourse","full_name":"artbez/hpcourse","owner":{"login":"artbez","id":6135618,"avatar_url":"https://avatars1.githubusercontent.com/u/6135618?v=4","gravatar_id":"","url":"https://api.github.com/users/artbez","html_url":"https://github.com/artbez","followers_url":"https://api.github.com/users/artbez/followers","following_url":"https://api.github.com/users/artbez/following{/other_user}","gists_url":"https://api.github.com/users/artbez/gists{/gist_id}","starred_url":"https://api.github.com/users/artbez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artbez/subscriptions","organizations_url":"https://api.github.com/users/artbez/orgs","repos_url":"https://api.github.com/users/artbez/repos","events_url":"https://api.github.com/users/artbez/events{/privacy}","received_events_url":"https://api.github.com/users/artbez/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/artbez/hpcourse","description":"Project is aimed to store student's practical works on high performance computing course","fork":true,"url":"https://api.github.com/repos/artbez/hpcourse","forks_url":"https://api.github.com/repos/artbez/hpcourse/forks","keys_url":"https://api.github.com/repos/artbez/hpcourse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/artbez/hpcourse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/artbez/hpcourse/teams","hooks_url":"https://api.github.com/repos/artbez/hpcourse/hooks","issue_events_url":"https://api.github.com/repos/artbez/hpcourse/issues/events{/number}","events_url":"https://api.github.com/repos/artbez/hpcourse/events","assignees_url":"https://api.github.com/repos/artbez/hpcourse/assignees{/user}","branches_url":"https://api.github.com/repos/artbez/hpcourse/branches{/branch}","tags_url":"https://api.github.com/repos/artbez/hpcourse/tags","blobs_url":"https://api.github.com/repos/artbez/hpcourse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/artbez/hpcourse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/artbez/hpcourse/git/refs{/sha}","trees_url":"https://api.github.com/repos/artbez/hpcourse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/artbez/hpcourse/statuses/{sha}","languages_url":"https://api.github.com/repos/artbez/hpcourse/languages","stargazers_url":"https://api.github.com/repos/artbez/hpcourse/stargazers","contributors_url":"https://api.github.com/repos/artbez/hpcourse/contributors","subscribers_url":"https://api.github.com/repos/artbez/hpcourse/subscribers","subscription_url":"https://api.github.com/repos/artbez/hpcourse/subscription","commits_url":"https://api.github.com/repos/artbez/hpcourse/commits{/sha}","git_commits_url":"https://api.github.com/repos/artbez/hpcourse/git/commits{/sha}","comments_url":"https://api.github.com/repos/artbez/hpcourse/comments{/number}","issue_comment_url":"https://api.github.com/repos/artbez/hpcourse/issues/comments{/number}","contents_url":"https://api.github.com/repos/artbez/hpcourse/contents/{+path}","compare_url":"https://api.github.com/repos/artbez/hpcourse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/artbez/hpcourse/merges","archive_url":"https://api.github.com/repos/artbez/hpcourse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/artbez/hpcourse/downloads","issues_url":"https://api.github.com/repos/artbez/hpcourse/issues{/number}","pulls_url":"https://api.github.com/repos/artbez/hpcourse/pulls{/number}","milestones_url":"https://api.github.com/repos/artbez/hpcourse/milestones{/number}","notifications_url":"https://api.github.com/repos/artbez/hpcourse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/artbez/hpcourse/labels{/name}","releases_url":"https://api.github.com/repos/artbez/hpcourse/releases{/id}","deployments_url":"https://api.github.com/repos/artbez/hpcourse/deployments","created_at":"2018-03-18T12:51:07Z","updated_at":"2018-03-19T23:27:21Z","pushed_at":"2018-03-19T23:27:19Z","git_url":"git://github.com/artbez/hpcourse.git","ssh_url":"git@github.com:artbez/hpcourse.git","clone_url":"https://github.com/artbez/hpcourse.git","svn_url":"https://github.com/artbez/hpcourse","homepage":null,"size":12496,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cscenter:master","ref":"master","sha":"8c4ad9224af04aea3d0d186a7e91b09f28b4defb","user":{"login":"cscenter","id":5622041,"avatar_url":"https://avatars3.githubusercontent.com/u/5622041?v=4","gravatar_id":"","url":"https://api.github.com/users/cscenter","html_url":"https://github.com/cscenter","followers_url":"https://api.github.com/users/cscenter/followers","following_url":"https://api.github.com/users/cscenter/following{/other_user}","gists_url":"https://api.github.com/users/cscenter/gists{/gist_id}","starred_url":"https://api.github.com/users/cscenter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cscenter/subscriptions","organizations_url":"https://api.github.com/users/cscenter/orgs","repos_url":"https://api.github.com/users/cscenter/repos","events_url":"https://api.github.com/users/cscenter/events{/privacy}","received_events_url":"https://api.github.com/users/cscenter/received_events","type":"Organization","site_admin":false},"repo":{"id":34339216,"name":"hpcourse","full_name":"cscenter/hpcourse","owner":{"login":"cscenter","id":5622041,"avatar_url":"https://avatars3.githubusercontent.com/u/5622041?v=4","gravatar_id":"","url":"https://api.github.com/users/cscenter","html_url":"https://github.com/cscenter","followers_url":"https://api.github.com/users/cscenter/followers","following_url":"https://api.github.com/users/cscenter/following{/other_user}","gists_url":"https://api.github.com/users/cscenter/gists{/gist_id}","starred_url":"https://api.github.com/users/cscenter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cscenter/subscriptions","organizations_url":"https://api.github.com/users/cscenter/orgs","repos_url":"https://api.github.com/users/cscenter/repos","events_url":"https://api.github.com/users/cscenter/events{/privacy}","received_events_url":"https://api.github.com/users/cscenter/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cscenter/hpcourse","description":"Project is aimed to store student's practical works on high performance computing course","fork":false,"url":"https://api.github.com/repos/cscenter/hpcourse","forks_url":"https://api.github.com/repos/cscenter/hpcourse/forks","keys_url":"https://api.github.com/repos/cscenter/hpcourse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cscenter/hpcourse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cscenter/hpcourse/teams","hooks_url":"https://api.github.com/repos/cscenter/hpcourse/hooks","issue_events_url":"https://api.github.com/repos/cscenter/hpcourse/issues/events{/number}","events_url":"https://api.github.com/repos/cscenter/hpcourse/events","assignees_url":"https://api.github.com/repos/cscenter/hpcourse/assignees{/user}","branches_url":"https://api.github.com/repos/cscenter/hpcourse/branches{/branch}","tags_url":"https://api.github.com/repos/cscenter/hpcourse/tags","blobs_url":"https://api.github.com/repos/cscenter/hpcourse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cscenter/hpcourse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cscenter/hpcourse/git/refs{/sha}","trees_url":"https://api.github.com/repos/cscenter/hpcourse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cscenter/hpcourse/statuses/{sha}","languages_url":"https://api.github.com/repos/cscenter/hpcourse/languages","stargazers_url":"https://api.github.com/repos/cscenter/hpcourse/stargazers","contributors_url":"https://api.github.com/repos/cscenter/hpcourse/contributors","subscribers_url":"https://api.github.com/repos/cscenter/hpcourse/subscribers","subscription_url":"https://api.github.com/repos/cscenter/hpcourse/subscription","commits_url":"https://api.github.com/repos/cscenter/hpcourse/commits{/sha}","git_commits_url":"https://api.github.com/repos/cscenter/hpcourse/git/commits{/sha}","comments_url":"https://api.github.com/repos/cscenter/hpcourse/comments{/number}","issue_comment_url":"https://api.github.com/repos/cscenter/hpcourse/issues/comments{/number}","contents_url":"https://api.github.com/repos/cscenter/hpcourse/contents/{+path}","compare_url":"https://api.github.com/repos/cscenter/hpcourse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cscenter/hpcourse/merges","archive_url":"https://api.github.com/repos/cscenter/hpcourse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cscenter/hpcourse/downloads","issues_url":"https://api.github.com/repos/cscenter/hpcourse/issues{/number}","pulls_url":"https://api.github.com/repos/cscenter/hpcourse/pulls{/number}","milestones_url":"https://api.github.com/repos/cscenter/hpcourse/milestones{/number}","notifications_url":"https://api.github.com/repos/cscenter/hpcourse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cscenter/hpcourse/labels{/name}","releases_url":"https://api.github.com/repos/cscenter/hpcourse/releases{/id}","deployments_url":"https://api.github.com/repos/cscenter/hpcourse/deployments","created_at":"2015-04-21T16:36:38Z","updated_at":"2018-03-20T17:52:56Z","pushed_at":"2018-03-20T17:52:54Z","git_url":"git://github.com/cscenter/hpcourse.git","ssh_url":"git@github.com:cscenter/hpcourse.git","clone_url":"https://github.com/cscenter/hpcourse.git","svn_url":"https://github.com/cscenter/hpcourse","homepage":null,"size":12511,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":107,"mirror_url":null,"archived":false,"open_issues_count":6,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0"},"forks":107,"open_issues":6,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cscenter/hpcourse/pulls/196"},"html":{"href":"https://github.com/cscenter/hpcourse/pull/196"},"issue":{"href":"https://api.github.com/repos/cscenter/hpcourse/issues/196"},"comments":{"href":"https://api.github.com/repos/cscenter/hpcourse/issues/196/comments"},"review_comments":{"href":"https://api.github.com/repos/cscenter/hpcourse/pulls/196/comments"},"review_comment":{"href":"https://api.github.com/repos/cscenter/hpcourse/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cscenter/hpcourse/pulls/196/commits"},"statuses":{"href":"https://api.github.com/repos/cscenter/hpcourse/statuses/b0282f202fcafcde0fe2e25d8d4e90b670eaacaa"}},"author_association":"NONE"}}
{"actor":{"display_login":"EduardovEduard"}}