{"id":15047624,"url":"https://github.com/BardiFarsi/ThreadPoolManager","last_synced_at":"2025-05-15T17:30:43.535Z","repository":{"id":242787465,"uuid":"810564579","full_name":"BardiFarsi/ThreadPoolManager","owner":"BardiFarsi","description":"ThreadPoolManager is a C++ project that implements an efficient multi-threading system using a thread pool for generic functions of the same type and different tasks. It includes task management, synchronization mechanisms, and thread-safe logging to demonstrate concurrent task execution.","archived":false,"fork":false,"pushed_at":"2024-06-05T21:37:50.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-19T19:44:05.906Z","etag":null,"topics":["cpp","cpp17","cpp20","cuda","cuda-programming","memory-management","multiprocessing","multithreading","parallel-computing","parallel-processing","parallel-programming","thread","thread-pool","thread-safety","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":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BardiFarsi.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":"2024-06-05T00:11:32.000Z","updated_at":"2024-06-05T21:35:29.000Z","dependencies_parsed_at":"2024-06-05T01:43:07.694Z","dependency_job_id":"f179438e-f9d8-4c06-9c5c-14b28ae4dfd0","html_url":"https://github.com/BardiFarsi/ThreadPoolManager","commit_stats":null,"previous_names":["bardiparsi/threadpoolmanager","bardifarsi/threadpoolmanager"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BardiFarsi%2FThreadPoolManager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BardiFarsi%2FThreadPoolManager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BardiFarsi%2FThreadPoolManager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BardiFarsi%2FThreadPoolManager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BardiFarsi","download_url":"https://codeload.github.com/BardiFarsi/ThreadPoolManager/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254388036,"owners_count":22062971,"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":["cpp","cpp17","cpp20","cuda","cuda-programming","memory-management","multiprocessing","multithreading","parallel-computing","parallel-processing","parallel-programming","thread","thread-pool","thread-safety","threadpool","threads","threadsafe"],"created_at":"2024-09-24T21:01:30.915Z","updated_at":"2025-05-15T17:30:43.264Z","avatar_url":"https://github.com/BardiFarsi.png","language":"C++","readme":"# ThreadPoolManager\n\nThreadPoolManager is a C++ project that implements an efficient multi-threading system using a thread pool for generic functions of the same type and different tasks. It includes task management, synchronization mechanisms, and thread-safe logging to demonstrate concurrent task execution.\n\n## Features\n\n- Efficient thread pooling\n- Task queue management\n- Synchronization mechanisms with mutexes and condition variables\n- Thread-safe logging system\n- Exception handling within tasks\n\n## Prerequisites\n\n- C++20 or later\n- A compatible compiler (MinGW G++) or Microsoft Visual C++ (MSVC)\n- CPU with more than 2 Threads\n\n## Installation\n\n1. Clone the repository:\n\n    ```sh\n    git clone https://github.com/yourusername/ThreadPoolManager.git\n    cd ThreadPoolManager\n    ```\n\n2. Build the project using CMake:\n\n    ```sh\n    mkdir build\n    cd build\n    cmake ..\n    make\n    ```\n# Contributing\n   Contributions are welcome! Please fork the repository and submit a pull request for any improvements or bug fixes.\n\n# License\n  This project is licensed under the GNU General Public License (GNU GPL). - see the LICENSE file for details.\n\n# Contact\nemail: farsi.masoud@gmail.com\nLinkedin: https://www.linkedin.com/in/bardiaparsi/\nGitHub: https://github.com/BardiParsi\n\n## Usage\n\n1. Run the executable:\n\n    ```sh\n    ./ThreadPoolManager\n    ```\n\n2. Modify the `main.cpp` file to change the tasks or the number of threads.\n\n## Project Structure\n\n- **src/**: Source files\n    - **main.cpp**: Entry point of the application\n    - **ThreadPool.cpp**: Implementation of the ThreadPool class\n    - **HeavyTask.cpp**: Implementation of the HeavyTask class\n    - **Logger.cpp**: Implementation of the Logger class\n- **include/**: Header files\n    - **ThreadPool.h**: Header for the ThreadPool class\n    - **HeavyTask.h**: Header for the HeavyTask class\n    - **Logger.h**: Header for the Logger class\n- **CMakeLists.txt**: CMake build configuration\n\n## Example\n\nHere is a simple example to demonstrate the usage:\n\n```cpp\n#include \u003ciostream\u003e\n#include \"ThreadPool.h\"\n#include \"Logger.h\"\n\nvoid taskSimulator(int id) {\n    std::ostringstream oss;\n    oss \u003c\u003c std::this_thread::get_id();\n    Logger::INFO(\"Task \" + std::to_string(id) + \" running on thread ID: \" + oss.str() + \"\\n\");\n    std::this_thread::sleep_for(std::chrono::milliseconds(1000));\n}\n\nint main() {\n    const int CPUThreadNum = std::thread::hardware_concurrency();\n    int numberOfThreads {CPUThreadNum};\n    assert(numberOfThreads \u003e= 2);\n\n    if (numberOfThreads \u003e= 2) {\n        ThreadPool pool(numberOfThreads);\n        for (int i = 0; i \u003c numberOfThreads; i++) {\n            pool.enqueueTask([i](){ taskSimulator(i); });\n        }\n    } else {\n        Logger::INFO(\"THERE ARE NOT ENOUGH CPU THREADS ON THIS DEVICE\");\n    }\n\n    std::this_thread::sleep_for(std::chrono::milliseconds(1000));\n    std::cin.get();\n\n    return 0;\n\n\n\n}\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBardiFarsi%2FThreadPoolManager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBardiFarsi%2FThreadPoolManager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBardiFarsi%2FThreadPoolManager/lists"}