{"id":13418751,"url":"https://github.com/vit-vit/CTPL","last_synced_at":"2025-03-15T04:30:27.915Z","repository":{"id":20239798,"uuid":"23511877","full_name":"vit-vit/CTPL","owner":"vit-vit","description":"Modern and efficient C++ Thread Pool Library","archived":false,"fork":false,"pushed_at":"2023-01-26T06:30:38.000Z","size":207,"stargazers_count":1798,"open_issues_count":27,"forks_count":334,"subscribers_count":57,"default_branch":"master","last_synced_at":"2024-10-22T21:33:20.198Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vit-vit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-31T11:12:30.000Z","updated_at":"2024-10-22T06:12:07.000Z","dependencies_parsed_at":"2023-02-14T14:46:32.092Z","dependency_job_id":null,"html_url":"https://github.com/vit-vit/CTPL","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vit-vit%2FCTPL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vit-vit%2FCTPL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vit-vit%2FCTPL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vit-vit%2FCTPL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vit-vit","download_url":"https://codeload.github.com/vit-vit/CTPL/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221536595,"owners_count":16839537,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T22:01:06.568Z","updated_at":"2025-03-15T04:30:27.909Z","avatar_url":"https://github.com/vit-vit.png","language":"C++","readme":"CTPL\n====\n\nModern and efficient C++ Thread Pool Library\n\n\nA thread pool is a programming pattern for parallel execution of jobs, http://en.wikipedia.org/wiki/Thread_pool_pattern.\n\nMore specifically, there are some threads dedicated to the pool and a container of jobs. The jobs come to the pool dynamically. A job is fetched and deleted from the container when there is an idle thread. The job is then run on that thread.\n\nA thread pool is helpful when you want to minimize time of loading and destroying threads and when you want to limit the number of parallel jobs that run simultanuasly. For example, time consuming event handlers may be processed in a thread pool to make UI more responsive.\n\nFeatures:\n- standard c++ language, tested to compile on MS Visual Studio 2013 (2012?), gcc 4.8.2 and mingw 4.8.1(with posix threads)\n- simple but effiecient solution, one header only, no need to compile a binary library\n- query the number of idle threads and resize the pool dynamically\n- one API to push to the thread pool any collable object: lambdas, functors, functions, result of bind expression\n- collable objects with variadic number of parameters plus index of the thread running the object\n- automatic template argument deduction\n- get returned value of any type with standard c++ futures\n- get fired exceptions with standard c++ futures\n- use for any purpose under Apache license\n- two variants, one depends on Boost Lockfree Queue library, http://boost.org, which is a header only library\n\n\nSample usage\n\n\u003ccode\u003evoid first(int id) {\n    std::cout \u003c\u003c \"hello from \" \u003c\u003c id \u003c\u003c '\\n';\n}\u003c/code\u003e\n\n\u003ccode\u003e\u0026#32;\u0026#32;struct Second {\n    void operator()(int id) const {\n        std::cout \u003c\u003c \"hello from \" \u003c\u003c id \u003c\u003c '\\n';\n    }\n} second;\n\n\u003ccode\u003evoid third(int id, const std::string \u0026 additional_param) {}\u003c/code\u003e\n\n\n\u003ccode\u003eint main () {\u003c/code\u003e\n\n\u003ccode\u003e\u0026#32;\u0026#32;\u0026#32;\u0026#32;ctpl::thread_pool p(2 /* two threads in the pool */);\u003c/code\u003e\n\n\u003ccode\u003e\u0026#32;\u0026#32;\u0026#32;\u0026#32;p.push(first);  // function\u003c/code\u003e\n\n\u003ccode\u003e\u0026#32;\u0026#32;\u0026#32;\u0026#32;p.push(third, \"additional_param\");\u003c/code\u003e\n\n\u003ccode\u003e\u0026#32;\u0026#32;\u0026#32;\u0026#32;p.push( \u0026#91;\u0026#93; (int id){\n  std::cout \u003c\u003c \"hello from \" \u003c\u003c id \u003c\u003c '\\n';\n});  // lambda\u003c/code\u003e\n\n\u003ccode\u003e\u0026#32;\u0026#32;\u0026#32;\u0026#32;p.push(std::ref(second));  // functor, reference\u003c/code\u003e\n\n\u003ccode\u003e\u0026#32;\u0026#32;\u0026#32;\u0026#32;p.push(const_cast\u0026#60;const Second \u0026\u0026#62;(second));  // functor, copy ctor\u003c/code\u003e\n\n\u003ccode\u003e\u0026#32;\u0026#32;\u0026#32;\u0026#32;p.push(std::move(second));  // functor, move ctor\u003c/code\u003e\n\n\u003ccode\u003e}\u003c/code\u003e\n","funding_links":[],"categories":["TODO scan for Android support in followings","Process, Thread \u0026 Coroutine","C++"],"sub_categories":["C++/C Toolkit"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvit-vit%2FCTPL","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvit-vit%2FCTPL","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvit-vit%2FCTPL/lists"}