{"id":20696961,"url":"https://github.com/smol-rs/easy-parallel","last_synced_at":"2025-05-15T14:07:25.071Z","repository":{"id":45825707,"uuid":"267161796","full_name":"smol-rs/easy-parallel","owner":"smol-rs","description":"Run closures in parallel","archived":false,"fork":false,"pushed_at":"2025-01-19T16:42:29.000Z","size":39,"stargazers_count":113,"open_issues_count":0,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-08T00:08:53.205Z","etag":null,"topics":["rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smol-rs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","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":"2020-05-26T22:06:57.000Z","updated_at":"2025-02-23T02:44:41.000Z","dependencies_parsed_at":"2024-06-19T01:24:39.249Z","dependency_job_id":"d3784f88-d5e8-4f3c-b717-dad2045ea7d6","html_url":"https://github.com/smol-rs/easy-parallel","commit_stats":{"total_commits":37,"total_committers":3,"mean_commits":"12.333333333333334","dds":0.5135135135135135,"last_synced_commit":"f17bf332776897ca7ee30e7824fb909a6de983ab"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smol-rs%2Feasy-parallel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smol-rs%2Feasy-parallel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smol-rs%2Feasy-parallel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smol-rs%2Feasy-parallel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smol-rs","download_url":"https://codeload.github.com/smol-rs/easy-parallel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253660656,"owners_count":21943817,"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":["rust"],"created_at":"2024-11-17T00:16:11.251Z","updated_at":"2025-05-15T14:07:20.059Z","avatar_url":"https://github.com/smol-rs.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# easy-parallel\n\n[![Build](https://github.com/smol-rs/easy-parallel/workflows/Build%20and%20test/badge.svg)](\nhttps://github.com/smol-rs/easy-parallel/actions)\n[![License](https://img.shields.io/badge/license-Apache--2.0_OR_MIT-blue.svg)](\nhttps://github.com/smol-rs/easy-parallel)\n[![Cargo](https://img.shields.io/crates/v/easy-parallel.svg)](\nhttps://crates.io/crates/easy-parallel)\n[![Documentation](https://docs.rs/easy-parallel/badge.svg)](\nhttps://docs.rs/easy-parallel)\n\nRun closures in parallel.\n\nThis is a simple primitive for spawning threads in bulk and waiting for them to complete.\nThreads are allowed to borrow local variables from the main thread.\n\n# Examples\n\nRun two threads that increment a number:\n\n```rust\nuse easy_parallel::Parallel;\nuse std::sync::Mutex;\n\nlet mut m = Mutex::new(0);\n\nParallel::new()\n    .add(|| *m.lock().unwrap() += 1)\n    .add(|| *m.lock().unwrap() += 1)\n    .run();\n\nassert_eq!(*m.get_mut().unwrap(), 2);\n```\n\nSquare each number of a vector on a different thread:\n\n```rust\nuse easy_parallel::Parallel;\n\nlet v = vec![10, 20, 30];\n\nlet squares = Parallel::new()\n    .each(0..v.len(), |i| v[i] * v[i])\n    .run();\n\nassert_eq!(squares, [100, 400, 900]);\n```\n\nCompute the sum of numbers in an array:\n\n```rust\nuse easy_parallel::Parallel;\n\nfn par_sum(v: \u0026[i32]) -\u003e i32 {\n    const THRESHOLD: usize = 2;\n\n    if v.len() \u003c= THRESHOLD {\n        v.iter().copied().sum()\n    } else {\n        let half = (v.len() + 1) / 2;\n        let sums = Parallel::new().each(v.chunks(half), par_sum).run();\n        sums.into_iter().sum()\n    }\n}\n\nlet v = [1, 25, -4, 10, 8];\nassert_eq!(par_sum(\u0026v), 40);\n```\n\n## License\n\nLicensed under either of\n\n * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n#### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmol-rs%2Feasy-parallel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmol-rs%2Feasy-parallel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmol-rs%2Feasy-parallel/lists"}