{"action":"created","comment":{"url":"https://api.github.com/repos/CompFUSE/DCA/pulls/comments/212793469","pull_request_review_id":149505169,"id":212793469,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMjc5MzQ2OQ==","diff_hunk":"@@ -0,0 +1,106 @@\n+// Copyright (C) 2012 Jakob Progsch, Václav Zeman\n+// Copyright (C) 2018 ETH Zurich\n+// Copyright (C) 2018 UT-Battelle, LLC\n+// All rights reserved.\n+//\n+// See LICENSE for terms of usage.\n+// See CITATION.md for citation guidelines, if DCA++ is used for scientific publications.\n+//\n+// Author: Giovanni Balduzzi (gbalduzz@itp.phys.ethz.ch)\n+//\n+// This file implements a thread pool based on the file\n+// https://github.com/progschj/ThreadPool/blob/master/ThreadPool.h.\n+// See COPYING for the license of the original work.\n+\n+#ifndef DCA_PARALLEL_STDTHREAD_THREAD_POOL_THREAD_POOL_HPP\n+#define DCA_PARALLEL_STDTHREAD_THREAD_POOL_THREAD_POOL_HPP\n+\n+#include <condition_variable>\n+#include <iostream>\n+#include <functional>\n+#include <future>\n+#include <memory>\n+#include <mutex>\n+#include <queue>\n+#include <stdexcept>\n+#include <thread>\n+#include <vector>\n+\n+namespace dca {\n+namespace parallel {\n+\n+class ThreadPool {\n+public:\n+  // Creates a pool with n_threads.\n+  ThreadPool(size_t n_threads = 0);\n+\n+  ThreadPool(const ThreadPool& other) = delete;\n+  ThreadPool(ThreadPool&& other) = default;\n+\n+  // Enlarge the pool to n_threads if the current number of threads in the pool is inferior.\n+  void enlarge(std::size_t n_threads);\n+\n+  // Call asynchronously the function f with arguments args. This method is thread safe.\n+  // Returns: a future to the result of f(args...).\n+  template <class F, class... Args>\n+  auto enqueue(F&& f, Args&&... args) -> std::future<typename std::result_of<F(Args...)>::type>;\n+\n+  // Conclude all the pending work and destroy the threds spawned by this class.\n+  ~ThreadPool();\n+\n+  // Returns the number of threads used by this class.\n+  std::size_t size() const {\n+    return workers_.size();\n+  }\n+\n+  // Returns a static instance.\n+  static ThreadPool& get_instance() {\n+    static ThreadPool global_pool;\n+    return global_pool;\n+  }\n+\n+private:\n+  void workerLoop(int id);\n+\n+  // need to keep track of threads so we can join them\n+  std::vector<std::thread> workers_;\n+  // the task queue\n+  std::vector<std::unique_ptr<std::queue<std::packaged_task<void()>>>> tasks_;","path":"include/dca/parallel/stdthread/thread_pool/thread_pool.hpp","position":null,"original_position":68,"commit_id":"b05b9438e6b40e160423ef891f85d20c7bc30a1c","original_commit_id":"6f10832838b77e4886ee10b2efc35fb81e22f23f","user":{"login":"gbalduzz","id":11310640,"node_id":"MDQ6VXNlcjExMzEwNjQw","avatar_url":"https://avatars3.githubusercontent.com/u/11310640?v=4","gravatar_id":"","url":"https://api.github.com/users/gbalduzz","html_url":"https://github.com/gbalduzz","followers_url":"https://api.github.com/users/gbalduzz/followers","following_url":"https://api.github.com/users/gbalduzz/following{/other_user}","gists_url":"https://api.github.com/users/gbalduzz/gists{/gist_id}","starred_url":"https://api.github.com/users/gbalduzz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gbalduzz/subscriptions","organizations_url":"https://api.github.com/users/gbalduzz/orgs","repos_url":"https://api.github.com/users/gbalduzz/repos","events_url":"https://api.github.com/users/gbalduzz/events{/privacy}","received_events_url":"https://api.github.com/users/gbalduzz/received_events","type":"User","site_admin":false},"body":"removed in b05b9438e6b40e160423ef891f85d20c7bc30a1c","created_at":"2018-08-25T08:59:49Z","updated_at":"2018-08-25T08:59:49Z","html_url":"https://github.com/CompFUSE/DCA/pull/9#discussion_r212793469","pull_request_url":"https://api.github.com/repos/CompFUSE/DCA/pulls/9","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/CompFUSE/DCA/pulls/comments/212793469"},"html":{"href":"https://github.com/CompFUSE/DCA/pull/9#discussion_r212793469"},"pull_request":{"href":"https://api.github.com/repos/CompFUSE/DCA/pulls/9"}},"in_reply_to_id":212738117},"pull_request":{"url":"https://api.github.com/repos/CompFUSE/DCA/pulls/9","id":210744446,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEwNzQ0NDQ2","html_url":"https://github.com/CompFUSE/DCA/pull/9","diff_url":"https://github.com/CompFUSE/DCA/pull/9.diff","patch_url":"https://github.com/CompFUSE/DCA/pull/9.patch","issue_url":"https://api.github.com/repos/CompFUSE/DCA/issues/9","number":9,"state":"open","locked":false,"title":"[WIP] gpu_trunk: thread pool","user":{"login":"PDoakORNL","id":11856692,"node_id":"MDQ6VXNlcjExODU2Njky","avatar_url":"https://avatars1.githubusercontent.com/u/11856692?v=4","gravatar_id":"","url":"https://api.github.com/users/PDoakORNL","html_url":"https://github.com/PDoakORNL","followers_url":"https://api.github.com/users/PDoakORNL/followers","following_url":"https://api.github.com/users/PDoakORNL/following{/other_user}","gists_url":"https://api.github.com/users/PDoakORNL/gists{/gist_id}","starred_url":"https://api.github.com/users/PDoakORNL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PDoakORNL/subscriptions","organizations_url":"https://api.github.com/users/PDoakORNL/orgs","repos_url":"https://api.github.com/users/PDoakORNL/repos","events_url":"https://api.github.com/users/PDoakORNL/events{/privacy}","received_events_url":"https://api.github.com/users/PDoakORNL/received_events","type":"User","site_admin":false},"body":"Should contain the development repo thread spawning fix.  Builds, still requires testing.","created_at":"2018-08-24T13:43:20Z","updated_at":"2018-08-25T08:59:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d5071161724c2a1dd812e50df65d5173e4928910","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/CompFUSE/DCA/pulls/9/commits","review_comments_url":"https://api.github.com/repos/CompFUSE/DCA/pulls/9/comments","review_comment_url":"https://api.github.com/repos/CompFUSE/DCA/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CompFUSE/DCA/issues/9/comments","statuses_url":"https://api.github.com/repos/CompFUSE/DCA/statuses/b05b9438e6b40e160423ef891f85d20c7bc30a1c","head":{"label":"PDoakORNL:std_thread_enhancement","ref":"std_thread_enhancement","sha":"b05b9438e6b40e160423ef891f85d20c7bc30a1c","user":{"login":"PDoakORNL","id":11856692,"node_id":"MDQ6VXNlcjExODU2Njky","avatar_url":"https://avatars1.githubusercontent.com/u/11856692?v=4","gravatar_id":"","url":"https://api.github.com/users/PDoakORNL","html_url":"https://github.com/PDoakORNL","followers_url":"https://api.github.com/users/PDoakORNL/followers","following_url":"https://api.github.com/users/PDoakORNL/following{/other_user}","gists_url":"https://api.github.com/users/PDoakORNL/gists{/gist_id}","starred_url":"https://api.github.com/users/PDoakORNL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PDoakORNL/subscriptions","organizations_url":"https://api.github.com/users/PDoakORNL/orgs","repos_url":"https://api.github.com/users/PDoakORNL/repos","events_url":"https://api.github.com/users/PDoakORNL/events{/privacy}","received_events_url":"https://api.github.com/users/PDoakORNL/received_events","type":"User","site_admin":false},"repo":{"id":144873086,"node_id":"MDEwOlJlcG9zaXRvcnkxNDQ4NzMwODY=","name":"DCA-2","full_name":"PDoakORNL/DCA-2","owner":{"login":"PDoakORNL","id":11856692,"node_id":"MDQ6VXNlcjExODU2Njky","avatar_url":"https://avatars1.githubusercontent.com/u/11856692?v=4","gravatar_id":"","url":"https://api.github.com/users/PDoakORNL","html_url":"https://github.com/PDoakORNL","followers_url":"https://api.github.com/users/PDoakORNL/followers","following_url":"https://api.github.com/users/PDoakORNL/following{/other_user}","gists_url":"https://api.github.com/users/PDoakORNL/gists{/gist_id}","starred_url":"https://api.github.com/users/PDoakORNL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PDoakORNL/subscriptions","organizations_url":"https://api.github.com/users/PDoakORNL/orgs","repos_url":"https://api.github.com/users/PDoakORNL/repos","events_url":"https://api.github.com/users/PDoakORNL/events{/privacy}","received_events_url":"https://api.github.com/users/PDoakORNL/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/PDoakORNL/DCA-2","description":"DCA++","fork":true,"url":"https://api.github.com/repos/PDoakORNL/DCA-2","forks_url":"https://api.github.com/repos/PDoakORNL/DCA-2/forks","keys_url":"https://api.github.com/repos/PDoakORNL/DCA-2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PDoakORNL/DCA-2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PDoakORNL/DCA-2/teams","hooks_url":"https://api.github.com/repos/PDoakORNL/DCA-2/hooks","issue_events_url":"https://api.github.com/repos/PDoakORNL/DCA-2/issues/events{/number}","events_url":"https://api.github.com/repos/PDoakORNL/DCA-2/events","assignees_url":"https://api.github.com/repos/PDoakORNL/DCA-2/assignees{/user}","branches_url":"https://api.github.com/repos/PDoakORNL/DCA-2/branches{/branch}","tags_url":"https://api.github.com/repos/PDoakORNL/DCA-2/tags","blobs_url":"https://api.github.com/repos/PDoakORNL/DCA-2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PDoakORNL/DCA-2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PDoakORNL/DCA-2/git/refs{/sha}","trees_url":"https://api.github.com/repos/PDoakORNL/DCA-2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PDoakORNL/DCA-2/statuses/{sha}","languages_url":"https://api.github.com/repos/PDoakORNL/DCA-2/languages","stargazers_url":"https://api.github.com/repos/PDoakORNL/DCA-2/stargazers","contributors_url":"https://api.github.com/repos/PDoakORNL/DCA-2/contributors","subscribers_url":"https://api.github.com/repos/PDoakORNL/DCA-2/subscribers","subscription_url":"https://api.github.com/repos/PDoakORNL/DCA-2/subscription","commits_url":"https://api.github.com/repos/PDoakORNL/DCA-2/commits{/sha}","git_commits_url":"https://api.github.com/repos/PDoakORNL/DCA-2/git/commits{/sha}","comments_url":"https://api.github.com/repos/PDoakORNL/DCA-2/comments{/number}","issue_comment_url":"https://api.github.com/repos/PDoakORNL/DCA-2/issues/comments{/number}","contents_url":"https://api.github.com/repos/PDoakORNL/DCA-2/contents/{+path}","compare_url":"https://api.github.com/repos/PDoakORNL/DCA-2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PDoakORNL/DCA-2/merges","archive_url":"https://api.github.com/repos/PDoakORNL/DCA-2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PDoakORNL/DCA-2/downloads","issues_url":"https://api.github.com/repos/PDoakORNL/DCA-2/issues{/number}","pulls_url":"https://api.github.com/repos/PDoakORNL/DCA-2/pulls{/number}","milestones_url":"https://api.github.com/repos/PDoakORNL/DCA-2/milestones{/number}","notifications_url":"https://api.github.com/repos/PDoakORNL/DCA-2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PDoakORNL/DCA-2/labels{/name}","releases_url":"https://api.github.com/repos/PDoakORNL/DCA-2/releases{/id}","deployments_url":"https://api.github.com/repos/PDoakORNL/DCA-2/deployments","created_at":"2018-08-15T15:49:59Z","updated_at":"2018-08-23T13:39:57Z","pushed_at":"2018-08-25T08:44:13Z","git_url":"git://github.com/PDoakORNL/DCA-2.git","ssh_url":"git@github.com:PDoakORNL/DCA-2.git","clone_url":"https://github.com/PDoakORNL/DCA-2.git","svn_url":"https://github.com/PDoakORNL/DCA-2","homepage":null,"size":57026,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"CompFUSE:master","ref":"master","sha":"12c6c1279139994e8eb1656806f4fbb235f49296","user":{"login":"CompFUSE","id":40608494,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQwNjA4NDk0","avatar_url":"https://avatars2.githubusercontent.com/u/40608494?v=4","gravatar_id":"","url":"https://api.github.com/users/CompFUSE","html_url":"https://github.com/CompFUSE","followers_url":"https://api.github.com/users/CompFUSE/followers","following_url":"https://api.github.com/users/CompFUSE/following{/other_user}","gists_url":"https://api.github.com/users/CompFUSE/gists{/gist_id}","starred_url":"https://api.github.com/users/CompFUSE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CompFUSE/subscriptions","organizations_url":"https://api.github.com/users/CompFUSE/orgs","repos_url":"https://api.github.com/users/CompFUSE/repos","events_url":"https://api.github.com/users/CompFUSE/events{/privacy}","received_events_url":"https://api.github.com/users/CompFUSE/received_events","type":"Organization","site_admin":false},"repo":{"id":141548240,"node_id":"MDEwOlJlcG9zaXRvcnkxNDE1NDgyNDA=","name":"DCA","full_name":"CompFUSE/DCA","owner":{"login":"CompFUSE","id":40608494,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQwNjA4NDk0","avatar_url":"https://avatars2.githubusercontent.com/u/40608494?v=4","gravatar_id":"","url":"https://api.github.com/users/CompFUSE","html_url":"https://github.com/CompFUSE","followers_url":"https://api.github.com/users/CompFUSE/followers","following_url":"https://api.github.com/users/CompFUSE/following{/other_user}","gists_url":"https://api.github.com/users/CompFUSE/gists{/gist_id}","starred_url":"https://api.github.com/users/CompFUSE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CompFUSE/subscriptions","organizations_url":"https://api.github.com/users/CompFUSE/orgs","repos_url":"https://api.github.com/users/CompFUSE/repos","events_url":"https://api.github.com/users/CompFUSE/events{/privacy}","received_events_url":"https://api.github.com/users/CompFUSE/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CompFUSE/DCA","description":"DCA++","fork":false,"url":"https://api.github.com/repos/CompFUSE/DCA","forks_url":"https://api.github.com/repos/CompFUSE/DCA/forks","keys_url":"https://api.github.com/repos/CompFUSE/DCA/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CompFUSE/DCA/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CompFUSE/DCA/teams","hooks_url":"https://api.github.com/repos/CompFUSE/DCA/hooks","issue_events_url":"https://api.github.com/repos/CompFUSE/DCA/issues/events{/number}","events_url":"https://api.github.com/repos/CompFUSE/DCA/events","assignees_url":"https://api.github.com/repos/CompFUSE/DCA/assignees{/user}","branches_url":"https://api.github.com/repos/CompFUSE/DCA/branches{/branch}","tags_url":"https://api.github.com/repos/CompFUSE/DCA/tags","blobs_url":"https://api.github.com/repos/CompFUSE/DCA/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CompFUSE/DCA/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CompFUSE/DCA/git/refs{/sha}","trees_url":"https://api.github.com/repos/CompFUSE/DCA/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CompFUSE/DCA/statuses/{sha}","languages_url":"https://api.github.com/repos/CompFUSE/DCA/languages","stargazers_url":"https://api.github.com/repos/CompFUSE/DCA/stargazers","contributors_url":"https://api.github.com/repos/CompFUSE/DCA/contributors","subscribers_url":"https://api.github.com/repos/CompFUSE/DCA/subscribers","subscription_url":"https://api.github.com/repos/CompFUSE/DCA/subscription","commits_url":"https://api.github.com/repos/CompFUSE/DCA/commits{/sha}","git_commits_url":"https://api.github.com/repos/CompFUSE/DCA/git/commits{/sha}","comments_url":"https://api.github.com/repos/CompFUSE/DCA/comments{/number}","issue_comment_url":"https://api.github.com/repos/CompFUSE/DCA/issues/comments{/number}","contents_url":"https://api.github.com/repos/CompFUSE/DCA/contents/{+path}","compare_url":"https://api.github.com/repos/CompFUSE/DCA/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CompFUSE/DCA/merges","archive_url":"https://api.github.com/repos/CompFUSE/DCA/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CompFUSE/DCA/downloads","issues_url":"https://api.github.com/repos/CompFUSE/DCA/issues{/number}","pulls_url":"https://api.github.com/repos/CompFUSE/DCA/pulls{/number}","milestones_url":"https://api.github.com/repos/CompFUSE/DCA/milestones{/number}","notifications_url":"https://api.github.com/repos/CompFUSE/DCA/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CompFUSE/DCA/labels{/name}","releases_url":"https://api.github.com/repos/CompFUSE/DCA/releases{/id}","deployments_url":"https://api.github.com/repos/CompFUSE/DCA/deployments","created_at":"2018-07-19T08:26:56Z","updated_at":"2018-08-24T22:17:50Z","pushed_at":"2018-08-25T08:44:14Z","git_url":"git://github.com/CompFUSE/DCA.git","ssh_url":"git@github.com:CompFUSE/DCA.git","clone_url":"https://github.com/CompFUSE/DCA.git","svn_url":"https://github.com/CompFUSE/DCA","homepage":null,"size":61787,"stargazers_count":6,"watchers_count":6,"language":"C++","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":8,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":1,"open_issues":8,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CompFUSE/DCA/pulls/9"},"html":{"href":"https://github.com/CompFUSE/DCA/pull/9"},"issue":{"href":"https://api.github.com/repos/CompFUSE/DCA/issues/9"},"comments":{"href":"https://api.github.com/repos/CompFUSE/DCA/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/CompFUSE/DCA/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/CompFUSE/DCA/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CompFUSE/DCA/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/CompFUSE/DCA/statuses/b05b9438e6b40e160423ef891f85d20c7bc30a1c"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"gbalduzz"}}