{"id":22284708,"url":"https://github.com/schets/consume","last_synced_at":"2025-07-28T22:30:50.749Z","repository":{"id":62438949,"uuid":"83173788","full_name":"schets/consume","owner":"schets","description":"Consume memory ordering in rust","archived":false,"fork":false,"pushed_at":"2017-02-26T01:08:09.000Z","size":2,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-18T21:42:58.944Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/schets.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":"2017-02-26T01:01:06.000Z","updated_at":"2019-05-13T16:45:44.000Z","dependencies_parsed_at":"2022-11-01T21:48:13.830Z","dependency_job_id":null,"html_url":"https://github.com/schets/consume","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/schets%2Fconsume","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schets%2Fconsume/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schets%2Fconsume/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schets%2Fconsume/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schets","download_url":"https://codeload.github.com/schets/consume/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227961890,"owners_count":17847836,"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-03T16:49:27.642Z","updated_at":"2024-12-03T16:49:28.425Z","avatar_url":"https://github.com/schets.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"This provides a consume ordering for when the compiler cannot elide the dependency\n\n# Examples\n\n```rust\nextern crate consume;\nuse std::sync::atomic::{AtomicPtr, AtomicUsize};\n\nfn consume_load(pt: \u0026AtomicPtr\u003c*const usize\u003e) -\u003e usize {\n    // There's a data dependency on the loaded value, \n    // meaning that the compiler can't od silly things to\n    // eliminate the dependency\n    unsafe { *pt.load(Consume) }\n}\n\nfn incorrect_consume_load(ind: \u0026AtomicUsize, vals: \u0026Vec\u003cusize\u003e) -\u003e usize {\n    // There is no data dependency here\n    // since the compiler can eliminate the loaded value\n    // from the pointer index. Ensure that you don't have this.\n    // Use consume at your own risk.\n    let i = ind.load(consume::Consume);\n    vals[ind - ind]\n    // vals[ind] would probably be correct, unless some shenanigans with the\n    // bounds checking occured. I only use vec for convenience, only\n    // use consume if you understand all possible data paths taken by the compiler\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschets%2Fconsume","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschets%2Fconsume","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschets%2Fconsume/lists"}