{"id":13648709,"url":"https://github.com/rust-osdev/spinning_top","last_synced_at":"2025-09-04T05:45:27.253Z","repository":{"id":51353504,"uuid":"240006273","full_name":"rust-osdev/spinning_top","owner":"rust-osdev","description":"A simple spinlock crate based on the abstractions provided by the `lock_api` crate.","archived":false,"fork":false,"pushed_at":"2023-10-19T05:52:22.000Z","size":105,"stargazers_count":37,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T01:08:46.381Z","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/rust-osdev.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","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}},"created_at":"2020-02-12T12:21:42.000Z","updated_at":"2025-03-15T02:42:09.000Z","dependencies_parsed_at":"2023-10-16T18:37:17.388Z","dependency_job_id":"320058e8-b69b-428f-a87a-9ecbf19788fe","html_url":"https://github.com/rust-osdev/spinning_top","commit_stats":{"total_commits":39,"total_committers":5,"mean_commits":7.8,"dds":"0.20512820512820518","last_synced_commit":"02fce2003438ce1b460c79dd4b0e4a9ef29f9ede"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-osdev%2Fspinning_top","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-osdev%2Fspinning_top/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-osdev%2Fspinning_top/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-osdev%2Fspinning_top/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rust-osdev","download_url":"https://codeload.github.com/rust-osdev/spinning_top/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137887,"owners_count":21053775,"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-08-02T01:04:28.313Z","updated_at":"2025-04-10T01:08:50.776Z","avatar_url":"https://github.com/rust-osdev.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# spinning_top\n\n\u003cimg alt=\"image of a spinning top\" align=\"right\" src=\"img/top.png\" height=120px\u003e\n\n[![Build Status](https://github.com/rust-osdev/spinning_top/workflows/Build/badge.svg)](https://github.com/rust-osdev/spinning_top/actions?query=workflow%3ABuild) [![Docs.rs Badge](https://docs.rs/spinning_top/badge.svg)](https://docs.rs/spinning_top/)\n\nA simple spinlock crate based on the abstractions provided by [`lock_api`].\n\n[`lock_api`]: https://docs.rs/lock_api/\n\n## Example\n\nFirst, import the crate as a dependency in your `Cargo.toml`. Then you can use it in the following way:\n\n```rust\nuse spinning_top::Spinlock;\n\nfn main() {\n    // Wrap some data in a spinlock\n    let data = String::from(\"Hello\");\n    let spinlock = Spinlock::new(data);\n    make_uppercase(\u0026spinlock); // only pass a shared reference\n    // We have ownership of the spinlock, so we can extract the data without locking\n    // Note: this consumes the spinlock\n    let data = spinlock.into_inner();\n    assert_eq!(data.as_str(), \"HELLO\");\n}\n\nfn make_uppercase(spinlock: \u0026Spinlock\u003cString\u003e) {\n    // Lock the spinlock to get a mutable reference to the data\n    let mut locked_data = spinlock.lock();\n    assert_eq!(locked_data.as_str(), \"Hello\");\n    locked_data.make_ascii_uppercase();\n\n    // the lock is automatically freed at the end of the scope\n}\n```\n\n`Spinlock::new` is a `const` function. This makes the `Spinlock` type\nusable in statics:\n\n```rust\nuse spinning_top::Spinlock;\n\nstatic DATA: Spinlock\u003cu32\u003e = Spinlock::new(0);\n\nfn main() {\n    let mut data = DATA.lock();\n    *data += 1;\n    assert_eq!(*data, 1);\n}\n```\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or\n  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\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-osdev%2Fspinning_top","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frust-osdev%2Fspinning_top","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-osdev%2Fspinning_top/lists"}