{"id":15047332,"url":"https://github.com/adityavk/thread-pool","last_synced_at":"2026-01-02T13:06:19.830Z","repository":{"id":237809866,"uuid":"795252621","full_name":"adityavk/thread-pool","owner":"adityavk","description":"A lightweight header-only C++11 thread pool library","archived":false,"fork":false,"pushed_at":"2024-05-02T23:04:32.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-20T18:33:45.403Z","etag":null,"topics":["concurrency","conditional-variables","cpp11","thread-pool"],"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/adityavk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2024-05-02T22:17:10.000Z","updated_at":"2024-05-02T23:05:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"758c89e3-0a31-4559-81eb-d0d5846b3c9f","html_url":"https://github.com/adityavk/thread-pool","commit_stats":null,"previous_names":["adityavk/thread-pool"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adityavk%2Fthread-pool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adityavk%2Fthread-pool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adityavk%2Fthread-pool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adityavk%2Fthread-pool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adityavk","download_url":"https://codeload.github.com/adityavk/thread-pool/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243495495,"owners_count":20299923,"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":["concurrency","conditional-variables","cpp11","thread-pool"],"created_at":"2024-09-24T20:56:44.325Z","updated_at":"2026-01-02T13:06:19.770Z","avatar_url":"https://github.com/adityavk.png","language":"C++","readme":"# Thread Pool Library\n\nA lightweight header-only C++11 library that provides a simple and efficient way to manage and execute tasks in parallel using a thread pool.\n\n## Getting Started\nSimply include the `ThreadPool.hpp` header file in your project.\n\n```cpp\n#include \"ThreadPool.hpp\"\n```\n\n## Example\nThe following example demonstrates how to use this library to calculate the sum of integers in the range [0, 1e9) modulo (1e9 + 7) using 6 threads.\n\n```cpp\n#include \u003ciostream\u003e\n#include \"ThreadPool.hpp\"\n\nint main() {\n    // Create a thread pool with 6 threads\n    ThreadPool threadPool(6);\n\n    // Define a task that calculates the sum of integers in the range [start, end) modulo (1e9 + 7)\n    auto sumTask = [](std::uint64_t start, std::uint64_t end, std::atomic\u003cint\u003e\u0026 result) {\n        int sum = 0;\n        for (std::uint64_t i = start; i \u003c end; ++i) {\n            sum = (sum + i) % 1000000007;\n        }\n        result = (result + sum) % 1000000007;\n    };\n\n    // Queue 100 tasks to calculate the sum of integers in the range [0, 1e9) in parallel\n    std::atomic\u003cint\u003e result(0);\n    for (std::uint64_t i = 0; i \u003c 100; ++i) {\n        threadPool.queue([i, \u0026sumTask, \u0026result] { sumTask(i * 10000000, (i + 1) * 10000000, result); });\n    }\n\n    // Wait for all tasks to complete\n    threadPool.waitForTasks();\n    std::cout \u003c\u003c \"Sum of integers in the range [0, 1e9) modulo (1e9 + 7) = \" \u003c\u003c result \u003c\u003c std::endl;\n\n    // Stop processing tasks: no more tasks will be queued, but the threads will continue processing the remaining tasks\n    // threadPool.stopProcessing();\n\n    return 0;\n}\n```\n\n## License\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE.md) file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadityavk%2Fthread-pool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadityavk%2Fthread-pool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadityavk%2Fthread-pool/lists"}