{"id":28386382,"url":"https://github.com/mxcaoalina/thread-pool","last_synced_at":"2025-06-26T13:31:15.143Z","repository":{"id":283419922,"uuid":"951708200","full_name":"mxcaoalina/thread-pool","owner":"mxcaoalina","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-20T05:45:38.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-30T18:39:21.144Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mxcaoalina.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-03-20T05:44:44.000Z","updated_at":"2025-03-20T05:45:41.000Z","dependencies_parsed_at":"2025-03-20T06:40:37.583Z","dependency_job_id":null,"html_url":"https://github.com/mxcaoalina/thread-pool","commit_stats":null,"previous_names":["mxcaoalina/thread-pool"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mxcaoalina/thread-pool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxcaoalina%2Fthread-pool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxcaoalina%2Fthread-pool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxcaoalina%2Fthread-pool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxcaoalina%2Fthread-pool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mxcaoalina","download_url":"https://codeload.github.com/mxcaoalina/thread-pool/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxcaoalina%2Fthread-pool/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262076469,"owners_count":23255018,"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":"2025-05-30T14:42:15.441Z","updated_at":"2025-06-26T13:31:15.129Z","avatar_url":"https://github.com/mxcaoalina.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Thread Pool Optimization System\n\nA high-performance, feature-rich thread pool implementation in C++ that includes adaptive scaling, deadlock detection, and performance monitoring.\n\n## Features\n\n- **Priority-based Task Scheduling**: Tasks are executed based on priority levels\n- **Adaptive Thread Scaling**: Automatically adjusts the number of worker threads based on workload\n- **Deadlock Detection**: Implements resource allocation graphs to detect potential deadlocks\n- **Performance Monitoring**: Tracks throughput and system metrics\n- **Thread-Safe Design**: Implements proper synchronization using mutexes and condition variables\n- **Resource Management**: Efficient handling of system resources\n\n## Building the Project\n\n### Prerequisites\n\n- C++17 or later\n- CMake 3.10 or later\n- A C++ compiler with thread support (GCC, Clang, or MSVC)\n\n### Build Instructions\n\n```bash\nmkdir build\ncd build\ncmake ..\ncmake --build .\n```\n\n## Usage Example\n\n```cpp\n#include \"thread_pool.hpp\"\n\nint main() {\n    // Create a thread pool with 2 initial threads and up to 5 max threads\n    ThreadPool pool(2, 5);\n\n    // Enqueue tasks with different priorities\n    for (int i = 0; i \u003c 10; ++i) {\n        pool.enqueue(Task{\n            [i]() {\n                // Your task implementation here\n                std::cout \u003c\u003c \"Task \" \u003c\u003c i \u003c\u003c \" executed.\\n\";\n            },\n            i % 3  // priority = 0,1,2 cycling\n        });\n    }\n\n    // Monitor performance\n    std::cout \u003c\u003c \"Current throughput: \" \u003c\u003c pool.getThroughput() \u003c\u003c \" tasks/sec\\n\";\n\n    // Clean shutdown\n    pool.shutdown();\n    return 0;\n}\n```\n\n## Project Structure\n\n```\n.\n├── CMakeLists.txt\n├── README.md\n├── include/\n│   └── thread_pool.hpp\n├── src/\n│   ├── thread_pool.cpp\n│   └── performance_monitor.cpp\n└── tests/\n    └── thread_pool_test.cpp\n```\n\n## Performance Monitoring\n\nThe system includes a built-in performance monitoring module that tracks:\n- Tasks processed per second\n- Queue size metrics\n- Thread utilization\n- Resource allocation patterns\n\n## Deadlock Detection\n\nThe thread pool implements a resource allocation graph algorithm to detect potential deadlocks. It tracks:\n- Resources held by each task\n- Resources requested by each task\n- Circular dependencies in resource allocation\n\n## License\n\nMIT License - feel free to use this code in your own projects.\n\n## Author\n\nMingxi Cao","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmxcaoalina%2Fthread-pool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmxcaoalina%2Fthread-pool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmxcaoalina%2Fthread-pool/lists"}