{"action":"created","comment":{"url":"https://api.github.com/repos/pingcap/tikv/pulls/comments/133345633","pull_request_review_id":56515960,"id":133345633,"diff_hunk":"@@ -254,115 +265,93 @@ where\n }\n \n // Each thread has a worker.\n-struct Worker<Q, T> {\n-    task_pool: Arc<(Mutex<TaskPool<Q, T>>, Condvar)>,\n+struct Worker<Q, T, C> {\n+    task_pool: TTaskPool<Q, T, C>,\n     task_count: Arc<AtomicUsize>,\n+    ctx: C,\n }\n \n-impl<Q, T> Worker<Q, T>\n+impl<Q, T, C> Worker<Q, T, C>\n where\n-    Q: ScheduleQueue<T>,\n+    Q: ScheduleQueue<T, C>,\n     T: Debug,\n+    C: Context,\n {\n-    fn new(\n-        task_pool: Arc<(Mutex<TaskPool<Q, T>>, Condvar)>,\n-        task_count: Arc<AtomicUsize>,\n-    ) -> Worker<Q, T> {\n+    fn new(task_pool: TTaskPool<Q, T, C>, task_count: Arc<AtomicUsize>, ctx: C) -> Worker<Q, T, C> {\n         Worker {\n             task_pool: task_pool,\n             task_count: task_count,\n+            ctx: ctx,\n+        }\n+    }\n+\n+    fn run(&mut self) {\n+        let mut task = self.get_next_task(None);\n+        // Start the worker. Loop breaks when receive stop message.\n+        while let Some(mut t) = task {\n+            // Since tikv would be down when any panic happens,\n+            // we don't need to process panic case here.\n+            t.ctx = (t.task)(t.ctx);","path":"src/util/threadpool.rs","position":277,"original_position":277,"commit_id":"6ec173b3db9464267a691dad069aad72c62c3ac5","original_commit_id":"6ec173b3db9464267a691dad069aad72c62c3ac5","user":{"login":"siddontang","id":1080370,"avatar_url":"https://avatars2.githubusercontent.com/u/1080370?v=4","gravatar_id":"","url":"https://api.github.com/users/siddontang","html_url":"https://github.com/siddontang","followers_url":"https://api.github.com/users/siddontang/followers","following_url":"https://api.github.com/users/siddontang/following{/other_user}","gists_url":"https://api.github.com/users/siddontang/gists{/gist_id}","starred_url":"https://api.github.com/users/siddontang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siddontang/subscriptions","organizations_url":"https://api.github.com/users/siddontang/orgs","repos_url":"https://api.github.com/users/siddontang/repos","events_url":"https://api.github.com/users/siddontang/events{/privacy}","received_events_url":"https://api.github.com/users/siddontang/received_events","type":"User","site_admin":false},"body":"why return context here, using &mut seems no need to return again. ","created_at":"2017-08-16T02:13:12Z","updated_at":"2017-08-16T02:13:12Z","html_url":"https://github.com/pingcap/tikv/pull/2152#discussion_r133345633","pull_request_url":"https://api.github.com/repos/pingcap/tikv/pulls/2152","_links":{"self":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/comments/133345633"},"html":{"href":"https://github.com/pingcap/tikv/pull/2152#discussion_r133345633"},"pull_request":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/2152"}}},"pull_request":{"url":"https://api.github.com/repos/pingcap/tikv/pulls/2152","id":135074925,"html_url":"https://github.com/pingcap/tikv/pull/2152","diff_url":"https://github.com/pingcap/tikv/pull/2152.diff","patch_url":"https://github.com/pingcap/tikv/pull/2152.patch","issue_url":"https://api.github.com/repos/pingcap/tikv/issues/2152","number":2152,"state":"open","locked":false,"title":"coprocesser: refactor thread pool to pass contexts","user":{"login":"choleraehyq","id":8923413,"avatar_url":"https://avatars3.githubusercontent.com/u/8923413?v=4","gravatar_id":"","url":"https://api.github.com/users/choleraehyq","html_url":"https://github.com/choleraehyq","followers_url":"https://api.github.com/users/choleraehyq/followers","following_url":"https://api.github.com/users/choleraehyq/following{/other_user}","gists_url":"https://api.github.com/users/choleraehyq/gists{/gist_id}","starred_url":"https://api.github.com/users/choleraehyq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/choleraehyq/subscriptions","organizations_url":"https://api.github.com/users/choleraehyq/orgs","repos_url":"https://api.github.com/users/choleraehyq/repos","events_url":"https://api.github.com/users/choleraehyq/events{/privacy}","received_events_url":"https://api.github.com/users/choleraehyq/received_events","type":"User","site_admin":false},"body":"@BusyJay @zhangjinpeng1987 @siddontang PTAL\r\n\r\nSigned-off-by: Cholerae Hu <huyingqian@pingcap.com>","created_at":"2017-08-10T09:06:27Z","updated_at":"2017-08-16T02:13:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"95c2387e6cefe77464c4b19e3bcb747b90ce53db","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/tikv/pulls/2152/commits","review_comments_url":"https://api.github.com/repos/pingcap/tikv/pulls/2152/comments","review_comment_url":"https://api.github.com/repos/pingcap/tikv/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/tikv/issues/2152/comments","statuses_url":"https://api.github.com/repos/pingcap/tikv/statuses/6ec173b3db9464267a691dad069aad72c62c3ac5","head":{"label":"pingcap:hyq/threadpool","ref":"hyq/threadpool","sha":"6ec173b3db9464267a691dad069aad72c62c3ac5","user":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":48833910,"name":"tikv","full_name":"pingcap/tikv","owner":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pingcap/tikv","description":"Distributed transactional key value database powered by Rust and Raft","fork":false,"url":"https://api.github.com/repos/pingcap/tikv","forks_url":"https://api.github.com/repos/pingcap/tikv/forks","keys_url":"https://api.github.com/repos/pingcap/tikv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/tikv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/tikv/teams","hooks_url":"https://api.github.com/repos/pingcap/tikv/hooks","issue_events_url":"https://api.github.com/repos/pingcap/tikv/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/tikv/events","assignees_url":"https://api.github.com/repos/pingcap/tikv/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/tikv/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/tikv/tags","blobs_url":"https://api.github.com/repos/pingcap/tikv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/tikv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/tikv/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/tikv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/tikv/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/tikv/languages","stargazers_url":"https://api.github.com/repos/pingcap/tikv/stargazers","contributors_url":"https://api.github.com/repos/pingcap/tikv/contributors","subscribers_url":"https://api.github.com/repos/pingcap/tikv/subscribers","subscription_url":"https://api.github.com/repos/pingcap/tikv/subscription","commits_url":"https://api.github.com/repos/pingcap/tikv/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/tikv/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/tikv/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/tikv/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/tikv/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/tikv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/tikv/merges","archive_url":"https://api.github.com/repos/pingcap/tikv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/tikv/downloads","issues_url":"https://api.github.com/repos/pingcap/tikv/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/tikv/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/tikv/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/tikv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/tikv/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/tikv/releases{/id}","deployments_url":"https://api.github.com/repos/pingcap/tikv/deployments","created_at":"2015-12-31T04:51:32Z","updated_at":"2017-08-15T16:40:40Z","pushed_at":"2017-08-15T16:03:48Z","git_url":"git://github.com/pingcap/tikv.git","ssh_url":"git@github.com:pingcap/tikv.git","clone_url":"https://github.com/pingcap/tikv.git","svn_url":"https://github.com/pingcap/tikv","homepage":"https://pingcap.com","size":10092,"stargazers_count":2072,"watchers_count":2072,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":228,"mirror_url":null,"open_issues_count":105,"forks":228,"open_issues":105,"watchers":2072,"default_branch":"master"}},"base":{"label":"pingcap:master","ref":"master","sha":"8b27de9c30b40caf6ffe92ece6a928bd3a63b85e","user":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":48833910,"name":"tikv","full_name":"pingcap/tikv","owner":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pingcap/tikv","description":"Distributed transactional key value database powered by Rust and Raft","fork":false,"url":"https://api.github.com/repos/pingcap/tikv","forks_url":"https://api.github.com/repos/pingcap/tikv/forks","keys_url":"https://api.github.com/repos/pingcap/tikv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/tikv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/tikv/teams","hooks_url":"https://api.github.com/repos/pingcap/tikv/hooks","issue_events_url":"https://api.github.com/repos/pingcap/tikv/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/tikv/events","assignees_url":"https://api.github.com/repos/pingcap/tikv/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/tikv/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/tikv/tags","blobs_url":"https://api.github.com/repos/pingcap/tikv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/tikv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/tikv/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/tikv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/tikv/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/tikv/languages","stargazers_url":"https://api.github.com/repos/pingcap/tikv/stargazers","contributors_url":"https://api.github.com/repos/pingcap/tikv/contributors","subscribers_url":"https://api.github.com/repos/pingcap/tikv/subscribers","subscription_url":"https://api.github.com/repos/pingcap/tikv/subscription","commits_url":"https://api.github.com/repos/pingcap/tikv/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/tikv/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/tikv/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/tikv/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/tikv/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/tikv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/tikv/merges","archive_url":"https://api.github.com/repos/pingcap/tikv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/tikv/downloads","issues_url":"https://api.github.com/repos/pingcap/tikv/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/tikv/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/tikv/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/tikv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/tikv/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/tikv/releases{/id}","deployments_url":"https://api.github.com/repos/pingcap/tikv/deployments","created_at":"2015-12-31T04:51:32Z","updated_at":"2017-08-15T16:40:40Z","pushed_at":"2017-08-15T16:03:48Z","git_url":"git://github.com/pingcap/tikv.git","ssh_url":"git@github.com:pingcap/tikv.git","clone_url":"https://github.com/pingcap/tikv.git","svn_url":"https://github.com/pingcap/tikv","homepage":"https://pingcap.com","size":10092,"stargazers_count":2072,"watchers_count":2072,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":228,"mirror_url":null,"open_issues_count":105,"forks":228,"open_issues":105,"watchers":2072,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/2152"},"html":{"href":"https://github.com/pingcap/tikv/pull/2152"},"issue":{"href":"https://api.github.com/repos/pingcap/tikv/issues/2152"},"comments":{"href":"https://api.github.com/repos/pingcap/tikv/issues/2152/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/2152/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/2152/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/tikv/statuses/6ec173b3db9464267a691dad069aad72c62c3ac5"}}}}
{"actor":{"display_login":"siddontang"}}