{"id":22297477,"url":"https://github.com/rustonaut/fuseflag","last_synced_at":"2025-03-25T22:43:48.063Z","repository":{"id":84690001,"uuid":"67738148","full_name":"rustonaut/fuseflag","owner":"rustonaut","description":"A (not resettable) fuse/flag which can be shared between different threads","archived":false,"fork":false,"pushed_at":"2016-09-09T18:16:22.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-30T20:14:51.820Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/rustonaut.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2016-09-08T20:32:46.000Z","updated_at":"2016-09-08T21:10:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"d2abfcdd-0591-4c07-afa2-d4f52e2279e9","html_url":"https://github.com/rustonaut/fuseflag","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/rustonaut%2Ffuseflag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustonaut%2Ffuseflag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustonaut%2Ffuseflag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustonaut%2Ffuseflag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rustonaut","download_url":"https://codeload.github.com/rustonaut/fuseflag/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245556960,"owners_count":20634889,"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-12-03T17:49:53.023Z","updated_at":"2025-03-25T22:43:48.043Z","avatar_url":"https://github.com/rustonaut.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# fuseflag \u0026emsp; [![Build Status](https://travis-ci.org/dathinab/fuseflag.svg?branch=master)](https://travis-ci.org/dathinab/fuseflag)\n\n**A (not resettable) fuse/flag which can be shared between different threads**\n\n---\n\nFuseflag provides a Fuse/Flag which can be shared (by cloning) between multiple threads.\nThe Fuse/Flag can be checked and burned, once burned it cannot be restored.\n\nA additional functionality is a wrapper around `thread::spawn` which takes a closure\nexpecting a `FuseFlag` as single parameter and returns a Wrapper  around `JoinHandle`\nwhich burns the fuse before calling join.\n\n## Example\n\n```rust\nextern crate fuseflag;\n\nuse std::time::Duration;\nuse std::thread::{sleep, spawn, JoinHandle};\n\nuse fuseflag::FuseFlag;\n\nfn background_job(end_flag: FuseFlag, id: u64) -\u003e JoinHandle\u003c()\u003e {\n    spawn(move || {\n        while end_flag.check() {\n            println!(\"\\tbg-job({}): continues workin\", id);\n            //Background work Work\n            sleep(Duration::from_millis(430*id));\n        }\n        println!(\"\\tbg-job({}) stops running\", id);\n    })\n}\n\nfn main() {\n    let end_fuse = FuseFlag::new();\n\n    let bg_guard = vec![\n        background_job(end_fuse.clone(), 1),\n        background_job(end_fuse.clone(), 2)\n    ];\n\n\n    println!(\"running fake ui loop...\");\n    //naturally a very nice ui called sleep ;)\n    sleep(Duration::from_secs(3));\n    println!(\"main loop ended: waiting for background jobs to stop\");\n\n    //this will trigger .check() to return false (for ever from now on)\n    end_fuse.burn();\n\n    //join the threads\n    for guard in bg_guard {\n        guard.join().unwrap();\n    }\n}\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 dual licensed as above, without any\nadditional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustonaut%2Ffuseflag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frustonaut%2Ffuseflag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustonaut%2Ffuseflag/lists"}