{"id":16915653,"url":"https://github.com/zesterer/lagoon","last_synced_at":"2025-10-12T02:19:16.858Z","repository":{"id":40345002,"uuid":"372896362","full_name":"zesterer/lagoon","owner":"zesterer","description":"A thread pool crate with an array of features","archived":false,"fork":false,"pushed_at":"2021-07-14T10:06:43.000Z","size":41,"stargazers_count":40,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-16T04:17:44.771Z","etag":null,"topics":["concurrency","pool","rust","thread"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/lagoon","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/zesterer.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":"2021-06-01T16:31:26.000Z","updated_at":"2024-11-06T22:06:25.000Z","dependencies_parsed_at":"2022-09-07T23:02:36.993Z","dependency_job_id":null,"html_url":"https://github.com/zesterer/lagoon","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/zesterer%2Flagoon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zesterer%2Flagoon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zesterer%2Flagoon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zesterer%2Flagoon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zesterer","download_url":"https://codeload.github.com/zesterer/lagoon/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243822294,"owners_count":20353500,"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":["concurrency","pool","rust","thread"],"created_at":"2024-10-13T19:21:42.706Z","updated_at":"2025-10-12T02:19:11.820Z","avatar_url":"https://github.com/zesterer.png","language":"Rust","readme":"# Lagoon\n\n[![Crates.io version](https://img.shields.io/crates/v/lagoon.svg)](https://crates.io/crates/lagoon)\n[![docs.rs](https://docs.rs/lagoon/badge.svg)](https://docs.rs/lagoon/)\n\nLagoon is a thread pool crate that aims to address many of the problems with existing thread pool crates.\n\n## Example\n\nLagoon's scoped jobs can be used for simple [rayon](https://github.com/rayon-rs/rayon/)-like data parallelism.\n\n```rust\n// A vector of the numbers 0 to 99\nlet mut data = (0..100).collect::\u003cVec\u003cu32\u003e\u003e();\n\nlagoon::ThreadPool::default().scoped(|s| {\n    // For each element in the vector...\n    for x in data.iter_mut() {\n        // ...spawn a job that squares that element\n        s.run(move || *x *= *x);\n    }\n});\n\n// Demonstrate that the elements have indeed been squared\nassert!((0..100)\n    .map(|x| x * x)\n    .zip(data.into_iter())\n    .all(|(x, y)| x == y));\n```\n\n## Features\n\n- **Scoped jobs**: Safely spawn jobs that have access to their parent scope!\n- **Job handles**: Receive the result of a job when it finishes, or wait on it to finish!\n- **Global pool**: A pay-for-what-you-use global thread pool that avoids dependencies fighting over resources!\n- **Customise thread attributes**: Specify thread name, stack size, etc.\n\n## Planned Features\n\n- **Async support for job waiting**: Use the thread pool in an async context!\n\n## Performance\n\nLagoon has very competitive performance. Below are timings required for each thread pool crate to spawn a new pool,\nexecute 100,000 trivial jobs, and then finish executing (i.e: smaller is better) compared to common alternative crates.\n\n# \u003cimg src=\"misc/perf.svg\" alt=\"Benchmark, demonstrating Lagoon's performance compared to other thread pool crates\"/\u003e\n\n```\nSpawning 100000 trivial tasks/lagoon     time:   [15.124 ms 16.437 ms 17.871 ms]\nSpawning 100000 trivial tasks/threadpool time:   [59.108 ms 59.549 ms 59.989 ms]\nSpawning 100000 trivial tasks/uvth       time:   [11.494 ms 12.598 ms 13.750 ms]\nSpawning 100000 trivial tasks/rusty_pool time:   [40.203 ms 44.778 ms 49.612 ms]\n```\n\nBenchmarks were run on an AMD Ryzen 7 3700x with 16 threads.\n\n## License\n\nLagoon is licensed under the MIT license (see `LICENSE`) in the main repository.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzesterer%2Flagoon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzesterer%2Flagoon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzesterer%2Flagoon/lists"}