{"id":20265485,"url":"https://github.com/dabbertorres/threadpool","last_synced_at":"2025-04-11T02:40:34.250Z","repository":{"id":62967002,"uuid":"45770514","full_name":"dabbertorres/ThreadPool","owner":"dabbertorres","description":"A thread pool for C++ using std::thread and other C++11/14 standard threading utilities.","archived":false,"fork":false,"pushed_at":"2018-07-22T18:35:28.000Z","size":24,"stargazers_count":35,"open_issues_count":0,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T00:15:25.276Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dabbertorres.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-11-08T07:01:01.000Z","updated_at":"2024-12-13T05:42:33.000Z","dependencies_parsed_at":"2022-11-10T02:00:56.340Z","dependency_job_id":null,"html_url":"https://github.com/dabbertorres/ThreadPool","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabbertorres%2FThreadPool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabbertorres%2FThreadPool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabbertorres%2FThreadPool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabbertorres%2FThreadPool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dabbertorres","download_url":"https://codeload.github.com/dabbertorres/ThreadPool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248330925,"owners_count":21085800,"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":"2024-11-14T11:48:33.198Z","updated_at":"2025-04-11T02:40:34.228Z","avatar_url":"https://github.com/dabbertorres.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ThreadPool\nA thread pool for C++ using std::thread and other C++11/14 standard threading utilities.\n\nEasy to use, with some extra functions for a bit more control.\n\n* #### `auto add(Func\u0026\u0026 func, Args\u0026\u0026... args)`\n\tThis is how jobs are added to the `ThreadPool`. Accepts a callable object (`func`) to be queued, along with arguments (`args...`). Returns a `std::future` templated to the return type of `Func`, to obtain the return value.\n\t\n\tFull signature:\n\t```cpp\n\ttemplate\u003ctypename Func, typename... Args\u003e\n\tauto add(Func\u0026\u0026 func, Args\u0026\u0026... args) -\u003e std::future\u003ctypename std::result_of\u003cFunc(Args...)\u003e::type\u003e;\n\t```\n\n* #### `std::size_t threadCount() const`\n\tReturns what the name implies: the number of threads used.\n\n* #### `std::size_t waitingJobs() const`\n\tReturns the number of jobs currently queued (not currently executing).\n\n* #### `Ids ids() const`\n\tReturns a list of the `std::thread::id`s assigned to the threads being used by the `ThreadPool`.\n\n\t```cpp\n\tusing Ids = std::vector\u003cstd::thread::id\u003e;\n\t```\n\n* #### `void clear()`\n\tClears the queue of waiting jobs. Does not affect currently executing jobs.\n\n* #### `void pause(bool state)`\n\tUpon being called:\n\tif `state` is true, prevents threads from grabbing another job upon completion of their current job until `pause(false)` is called.\n\t\n\tif `state` is false, allows threads to grab more jobs as they finish. This is the default state.\n\n\tNote: calling `wait()` will not *wait* if `pause(true)` was called last (ie: call `pause(false)` after `pause(true)` and before `wait()`).\n\n* #### `void wait()`\n\tBlocks until the number of threads waiting for a job is equal to the number of threads (ie: until all threads have nothing to execute).\n\n* #### Destructor Note\n\tThe destructor does not wait for queued jobs to be finished. It first clears the queue (call to `clear()`), tells threads to close, wakes up any waiting threads, and then joins to all of them. If you want to wait until the `ThreadPool` is done, call `wait()` before its lifetime ends.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdabbertorres%2Fthreadpool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdabbertorres%2Fthreadpool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdabbertorres%2Fthreadpool/lists"}