{"id":24656723,"url":"https://github.com/jgardona/rpools","last_synced_at":"2025-10-07T17:31:52.118Z","repository":{"id":210202260,"uuid":"726017626","full_name":"jgardona/rpools","owner":"jgardona","description":"A minimalist rust workerpool implementation that uses channels to synchronize the jobs. It can spawn a fixed number of worker threads, that waits for a job queue.","archived":false,"fork":false,"pushed_at":"2023-12-13T16:58:06.000Z","size":13,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-03T03:02:01.891Z","etag":null,"topics":["concurrency","library","threadpool","worker-pool"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/jgardona.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}},"created_at":"2023-12-01T11:05:00.000Z","updated_at":"2024-08-28T06:29:21.000Z","dependencies_parsed_at":"2023-12-13T18:29:14.548Z","dependency_job_id":"8097bbea-1dfc-413c-8371-d6b7bbb9aa59","html_url":"https://github.com/jgardona/rpools","commit_stats":null,"previous_names":["jgardona/rpools"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jgardona/rpools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgardona%2Frpools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgardona%2Frpools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgardona%2Frpools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgardona%2Frpools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jgardona","download_url":"https://codeload.github.com/jgardona/rpools/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgardona%2Frpools/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278813366,"owners_count":26050539,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","library","threadpool","worker-pool"],"created_at":"2025-01-25T23:56:46.902Z","updated_at":"2025-10-07T17:31:51.832Z","avatar_url":"https://github.com/jgardona.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rpools\r\n\r\n\u003cp align=\"center\"\u003e\r\n  \u003ca href=\"https://crates.io/crates/rpools\"\u003e\r\n    \u003cimg src=\"https://img.shields.io/crates/v/rpools.svg\" alt=\"Crates.io\"/\u003e\r\n  \u003c/a\u003e\r\n  \u003ca href=\"https://crates.io/crates/rpools\"\u003e\r\n    \u003cimg src=\"https://img.shields.io/crates/d/rpools\" alt=\"Crates.io Downloads\"/\u003e\r\n  \u003c/a\u003e\r\n  \u003cimg src=\"https://img.shields.io/badge/rust-stable-orange\" alt=\"Rust Stable\"/\u003e\r\n  \u003ca href=\"https://opensource.org/licenses/MIT\"\u003e\r\n    \u003cimg src=\"https://img.shields.io/crates/l/rpools.svg\" alt=\"License\"/\u003e\r\n  \u003c/a\u003e\r\n  \u003ca href=\"https://github.com/jgardona/rpools/actions/workflows/rust.yml\"\u003e\r\n    \u003cimg src=\"https://github.com/jgardona/rpools/actions/workflows/rust.yml/badge.svg\" alt=\"GitHub Actions Workflow Status\"/\u003e\r\n  \u003c/a\u003e\r\n\u003c/p\u003e\r\n\r\n\r\nA minimalist rust workerpool implementation that uses channels to synchronize the jobs. It can spawn a fixed number of worker threads, that waits for a job queue.\r\n\r\n## Install\r\n\r\n```\r\n$ cargo add rpools\r\n``` \r\n\r\n## Usage\r\n\r\n* **A simple workerpool**\r\n```rust\r\n use rpools::pool::WorkerPool;\r\n use std::sync::mpsc::channel;\r\n use std::sync::{Arc, Mutex};\r\n\r\n let n_workers = 4;\r\n let n_jobs = 8;\r\n let pool = WorkerPool::new(n_workers);\r\n\r\n let (tx, rx) = channel();\r\n let atx = Arc::new(Mutex::new(tx));\r\n for _ in 0..n_jobs {\r\n     let atx = atx.clone();\r\n     pool.execute(move|| {\r\n         let tx = atx.lock().unwrap();\r\n\r\n            // a long task goes here\r\n            // send results to channel (use it to sync the pool with the parent thread)\r\n\r\n         tx.send(1).expect(\"channel will be there waiting for the pool\");\r\n     });\r\n }\r\n\r\n assert_eq!(rx.iter().take(n_jobs).fold(0, |a, b| a + b), 8);\r\n```\r\n\r\n* **Use sync module to synchronize your pool**\r\n\r\n```rust\r\nlet njobs = 20;\r\nlet nworkers = 3;\r\nlet pool = pool::WorkerPool::new(nworkers);\r\nlet atomic = Arc::new(AtomicUsize::new(0));\r\nlet wg = WaitGroup::default();\r\n\r\n// send the jobs to the pool\r\nfor _ in 0..njobs {\r\n    let wg = wg.clone();\r\n    let atomic = atomic.clone();\r\n    pool.execute(move || {\r\n        atomic.fetch_add(1, Ordering::Relaxed);\r\n        drop(wg);\r\n    });\r\n}\r\n\r\n// wait for the pool finnishes\r\nwg.wait();\r\nassert_eq!(njobs, atomic.load(Ordering::Relaxed));\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgardona%2Frpools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjgardona%2Frpools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgardona%2Frpools/lists"}