{"id":25049203,"url":"https://github.com/its-laika/crates","last_synced_at":"2026-02-11T10:31:30.186Z","repository":{"id":275668219,"uuid":"926809697","full_name":"its-laika/crates","owner":"its-laika","description":"All my crates bundled into one namespace","archived":false,"fork":false,"pushed_at":"2025-02-04T22:10:16.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-04T22:17:21.975Z","etag":null,"topics":["rust","rust-lang","spmc"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/laika","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/its-laika.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":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-03T22:26:12.000Z","updated_at":"2025-02-04T22:15:49.000Z","dependencies_parsed_at":"2025-02-03T23:38:36.424Z","dependency_job_id":null,"html_url":"https://github.com/its-laika/crates","commit_stats":null,"previous_names":["its-laika/shotgun","its-laika/crates"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/its-laika%2Fcrates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/its-laika%2Fcrates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/its-laika%2Fcrates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/its-laika%2Fcrates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/its-laika","download_url":"https://codeload.github.com/its-laika/crates/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246413377,"owners_count":20773053,"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","rust-lang","spmc"],"created_at":"2025-02-06T08:16:52.227Z","updated_at":"2025-03-31T03:32:00.055Z","avatar_url":"https://github.com/its-laika.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laika's namespace crate \n\n**This module contains multiple submodules (included via feature flags) with\ndifferent functionalities. They're all grouped under the `laika` namespace,\nproviding some kind of scoped crates (avoiding naming conflicts).**\n\n## Submodules / Features\n\n## shotgun\n_A dead simple one-shot single producer, multiple consumer (SPMC) channel_\n\n### About\nShotgun is a simple one-shot single producer, multiple consumer (SPMC) channel.\nIt internally uses `std::sync::Mutex` and `std::sync::Arc` and does not contain\nany unsafe code.\n\n### When to use\n\nLikely when you need to pass a signal to multiple threads or functions to stop\nin order to shut down the application.\n\n### How to use\n\n#### Synchronous\n```rust\nfn main() {\n    use laika::shotgun::channel;\n    use std::thread;\n    use std::time;\n\n    let (tx, rx) = channel();\n\n    let rx1 = rx.clone();\n    let thread1 = thread::spawn(move || loop {\n        if rx1.try_recv().is_some() {\n            return 1;\n        }\n\n        thread::sleep(time::Duration::from_secs(1));\n    });\n\n    let rx2 = rx.clone();\n    let thread2 = thread::spawn(move || loop {\n        if rx2.try_recv().is_some() {\n            return 2;\n        }\n\n        thread::sleep(time::Duration::from_secs(1));\n    });\n\n    thread::sleep(time::Duration::from_secs(2));\n\n    tx.send(()); // `tx` is dropped here.\n\n    assert!(thread1.join().is_ok_and(|v| v == 1));\n    assert!(thread2.join().is_ok_and(|v| v == 2));\n}\n```\n\n#### Asynchronous\n```rust\n#[tokio]\nasync fn main() {\n    use shotgun::channel;\n    use std::thread;\n    use std::time;\n\n    let (tx, rx) = channel();\n\n    let rx1 = rx.clone();\n    let fun1 = async move {\n        rx1.await;\n        1\n    };\n\n    let rx2 = rx.clone();\n    let fun2 = async move {\n        // Explicit call to recv(), does the same as calling`.await` directly.\n        rx2.recv().await;\n        2\n    };\n\n    thread::sleep(time::Duration::from_secs(2));\n\n    tx.send(());\n\n    let rx3 = rx.clone();\n    let fun3 = async move {\n        rx3.await;\n        3\n    };\n\n    let result = join!(fun1, fun2);\n\n    assert_eq!(result.0, 1);\n    assert_eq!(result.1, 2);\n    assert_eq!(fun3.await, 3);\n}\n```\n\n# License\n[MIT](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fits-laika%2Fcrates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fits-laika%2Fcrates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fits-laika%2Fcrates/lists"}