{"id":20549511,"url":"https://github.com/edenreich/threadpool-component","last_synced_at":"2025-03-06T05:28:54.875Z","repository":{"id":105873693,"uuid":"212159416","full_name":"edenreich/threadpool-component","owner":"edenreich","description":"An easy to use component for creating a thread pool written in C++","archived":false,"fork":false,"pushed_at":"2019-10-02T21:45:02.000Z","size":30,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-16T16:42:44.308Z","etag":null,"topics":["cmake","event-loop","threadpool","threads","threadsafe"],"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/edenreich.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-01T17:37:24.000Z","updated_at":"2023-04-03T18:43:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"0bd374bd-4c11-4f22-b1d3-9dafa5951125","html_url":"https://github.com/edenreich/threadpool-component","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edenreich%2Fthreadpool-component","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edenreich%2Fthreadpool-component/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edenreich%2Fthreadpool-component/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edenreich%2Fthreadpool-component/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edenreich","download_url":"https://codeload.github.com/edenreich/threadpool-component/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242153698,"owners_count":20080539,"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":["cmake","event-loop","threadpool","threads","threadsafe"],"created_at":"2024-11-16T02:18:16.202Z","updated_at":"2025-03-06T05:28:54.867Z","avatar_url":"https://github.com/edenreich.png","language":"C++","readme":"\n\u003cp\u003e\n  \u003ca href=\"https://github.com/edenreich/threadpool-component\"\u003e\u003cimg alt=\"Build Status\" src=\"https://github.com/edenreich/threadpool-component/workflows/build/badge.svg\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# Thread Pool Component\n\nAn easy to use component for creating a thread pool written in C++\n\n## Usage\n\n```cpp\n// main.cpp\n#include \u003cthread/pool_factory.h\u003e\n\n#include \u003cchrono\u003e\n#include \u003cthread\u003e\n#include \u003ciostream\u003e\n\n\nint main(int argc, char ** argv) {\n\n    // Check how many threads supported on the current hardware.\n    unsigned int concurentThreadsSupported = std::thread::hardware_concurrency();\n\n    // Create the pool.\n    Thread::Interfaces::PoolInterface * pool = Thread::PoolFactory::make(concurentThreadsSupported);\n\n    // Enqueue 10 requests to process, this could be processed simultaneously.\n    // It's only push these handlers to the queue, and they will be picked up by the next available thread.\n    for (unsigned int request = 1; request \u003c= 10; ++request) {\n        pool-\u003eenqueue([=](std::thread::id threadId) {            \n            // Demonstrate a long running process\n            for (unsigned int i = 0; i \u003c 10; i++) {\n                std::cout \u003c\u003c \"\\nProcessing Request Nr. \" \u003c\u003c request \u003c\u003c \" by thread id \" \u003c\u003c threadId \u003c\u003c '\\n';\n                std::this_thread::sleep_for(std::chrono::milliseconds(500));\n            }\n\n            std::cout \u003c\u003c \"\\nProcessing Request Nr. \" \u003c\u003c request \u003c\u003c \" has finished!\" \u003c\u003c '\\n';\n        });\n    }\n\n    // If for whatever reason the \"web server\" shutdown, \n    // shutdown also the pool (join the threads to the main context).\n    pool-\u003eshutdown();\n\n    std::cout \u003c\u003c \"\\nPool has been destroyed\" \u003c\u003c '\\n';\n\n    return 0;\n}\n```\n\n## Build\n\nRun `cd build \u0026\u0026 cmake .. \u0026\u0026 cmake --build . --target install`\n\n## Distributed Files\n\nAfter building the project all distributed files are located in `build/dist`.\n\n## Target\n\nThis project targets all platforms (it's STL-Based).\n\n## Contributing Guidelines\n\nIf you find this project interesting or have any suggestions, feel free to send a pull request. I will be more than happy to review it.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedenreich%2Fthreadpool-component","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedenreich%2Fthreadpool-component","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedenreich%2Fthreadpool-component/lists"}