{"id":15571003,"url":"https://github.com/netromdk/threadpool","last_synced_at":"2026-04-29T03:06:51.631Z","repository":{"id":75034314,"uuid":"42004141","full_name":"netromdk/threadpool","owner":"netromdk","description":"Thread pool purely written in C++11.","archived":false,"fork":false,"pushed_at":"2015-09-08T00:00:00.000Z","size":180,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-31T21:12:45.940Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/netromdk.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":"2015-09-06T13:47:11.000Z","updated_at":"2018-07-09T01:22:45.000Z","dependencies_parsed_at":"2023-03-11T18:23:06.810Z","dependency_job_id":null,"html_url":"https://github.com/netromdk/threadpool","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/netromdk/threadpool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netromdk%2Fthreadpool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netromdk%2Fthreadpool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netromdk%2Fthreadpool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netromdk%2Fthreadpool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netromdk","download_url":"https://codeload.github.com/netromdk/threadpool/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netromdk%2Fthreadpool/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32408462,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T02:37:21.628Z","status":"ssl_error","status_checked_at":"2026-04-29T02:36:50.947Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-10-02T17:53:01.371Z","updated_at":"2026-04-29T03:06:51.604Z","avatar_url":"https://github.com/netromdk.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"ThreadPool\n==========\n\nThreadPool is a templated, include-only library written entirely in C++11. No linking required.\n\nIt works by simply adding a number of tasks to be computed and then processing them. By default it will use as many software threads as there are hardware threads on the system.\n\nUsage\n=====\nThe pool is easy to use: add some tasks and process them:\n\n```cpp\n#include \"ThreadPool.h\"\n\nThreadPool\u003cvoid\u003e pool;\nfor (int i = 0; i \u003c 10; i++) {\n  pool.queueTask([]{\n      /* do work */\n    });\n }\n\n// Blocks until all tasks have been processed.\npool.process();\n```\n\nIf the tasks yield a result then those can easily be used afterwards:\n```cpp\n#include \"ThreadPool.h\"\n\nThreadPool\u003cint\u003e pool;\nfor (int i = 0; i \u003c 10; i++) {\n  pool.queueTask([]{\n      /* do work */\n      return /* result */;\n    });\n }\n\npool.process();\n\nfor (auto \u0026future : pool.getFutures()) {\n  auto value = future.get();\n  /* use results */\n}\n```\n\nIn some cases you don't want it to be blocking so you can have it invoke a callback on completion:\n```cpp\n#include \"ThreadPool.h\"\n\nThreadPool\u003cvoid\u003e pool;\nfor (int i = 0; i \u003c 10; i++) {\n  pool.queueTask([]{\n      /* do work */\n    });\n }\n\npool.process([]{\n    /* called when done with all tasks */\n  });\n  \n// Continues with program while tasks are being processed..\n```\n\nTests\n=====\n\nRequires a C++11 compliant compiler (GCC 4.8+, Clang 3.3+ etc.) and CMake 3+.\n\nWhile the library is include-only there are a few test programs which can be compiled and tried out:\n\n1. Extract source and go into the diretory.\n2. `mkdir build`\n3. `cd build`\n4. `cmake ..`\n5. `make`\n\nThis will produce the following test programs in the \"bin\" folder:\n* intpool - Tests a simple pool with integer results.\n* voidpool - Tests a simple pool with no results.\n* sum - Asynchronally sums all numbers of a vector.\n* funcpool - Tests a simple pool with lvalue funcs.\n* callback - Tests non-blocking process() with a callback.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetromdk%2Fthreadpool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetromdk%2Fthreadpool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetromdk%2Fthreadpool/lists"}