{"id":16475978,"url":"https://github.com/softprops/waitout","last_synced_at":"2025-03-23T11:32:56.020Z","repository":{"id":57671824,"uuid":"46327870","full_name":"softprops/waitout","owner":"softprops","description":"awaits the completion of multiple async tasks","archived":false,"fork":false,"pushed_at":"2015-11-29T01:41:46.000Z","size":524,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-17T12:00:05.724Z","etag":null,"topics":[],"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/softprops.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-17T06:31:39.000Z","updated_at":"2019-08-10T14:26:22.000Z","dependencies_parsed_at":"2022-08-30T15:41:21.918Z","dependency_job_id":null,"html_url":"https://github.com/softprops/waitout","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Fwaitout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Fwaitout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Fwaitout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Fwaitout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/softprops","download_url":"https://codeload.github.com/softprops/waitout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245097158,"owners_count":20560311,"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-10-11T12:41:08.369Z","updated_at":"2025-03-23T11:32:55.608Z","avatar_url":"https://github.com/softprops.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# waitout\n\n[![Build Status](https://travis-ci.org/softprops/waitout.svg?branch=master)](https://travis-ci.org/softprops/waitout)\n\nWaitout provides a simple interface for tracking and awaiting the completion of multiple\nasynchounous tasks.\n\n## api docs\n\nFind them [here](https://softprops.github.io/waitout).\n\n## install\n\nAdd the following to you're `Cargo.toml` file\n\n```toml\n[dependencies]\nwaitout = \"0.1\"\n```\n\n## usage\n\nIt's sometimes useful to fan out independant tasks asynchronously for efficient completion of\nan aggregate task. Asynchronous tasks may sometimes be staged in various scopes making it difficult\nto monitor the current state of their completion. Some languages have std library interfaces like [CountDownLatches](http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CountDownLatch.html) and [WaitGroups](https://golang.org/pkg/sync/#WaitGroup) to help solve this problem. Absent of a similar interface in rust, the motivation for waitout was born.\n\nWaitout is a simple wrapper around of few rust synchronisation primitives that make staged task completion more straight forward.\nThe idea is simple, keep reference create a shared counter that increments for every task you wish to wait on.\nWhen a task completes decrement that counter. When the counter reaches 0, the current thread may proceed.\n\n```rust\nextern crate waitout;\n\nuse std::sync::Arc;\nuse std::thread;\nuse waitout::WaitGroup;\n\nfn main() {\n    let wg = Arc::new(\n        WaitGroup::new(0)\n    );\n    for _ in 0..100 {\n        wg.add(1);\n        let wg2 = wg.clone();\n        thread::spawn(move|| {\n            thread::sleep_ms(2000);\n            wg2.done();\n        });\n    }\n    wg.wait();\n    println!(\"all set\")\n}\n```\n\nDoug Tangren (softprops) 2015\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftprops%2Fwaitout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoftprops%2Fwaitout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftprops%2Fwaitout/lists"}