{"id":20696938,"url":"https://github.com/smol-rs/parking","last_synced_at":"2025-04-08T01:35:47.666Z","repository":{"id":40651015,"uuid":"264452126","full_name":"smol-rs/parking","owner":"smol-rs","description":"Thread parking and unparking","archived":false,"fork":false,"pushed_at":"2025-01-19T16:20:45.000Z","size":43,"stargazers_count":74,"open_issues_count":2,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-01T00:34:01.020Z","etag":null,"topics":["rust"],"latest_commit_sha":null,"homepage":"","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/smol-rs.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-16T14:14:05.000Z","updated_at":"2025-01-19T16:20:45.000Z","dependencies_parsed_at":"2023-01-31T05:30:30.667Z","dependency_job_id":"eef640b7-e391-4290-82c6-b7b10ccc8ea6","html_url":"https://github.com/smol-rs/parking","commit_stats":{"total_commits":57,"total_committers":8,"mean_commits":7.125,"dds":0.543859649122807,"last_synced_commit":"4d8ed214318bcd8c1e790259003317869428016b"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smol-rs%2Fparking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smol-rs%2Fparking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smol-rs%2Fparking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smol-rs%2Fparking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smol-rs","download_url":"https://codeload.github.com/smol-rs/parking/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247761051,"owners_count":20991531,"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"],"created_at":"2024-11-17T00:16:03.430Z","updated_at":"2025-04-08T01:35:47.641Z","avatar_url":"https://github.com/smol-rs.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# parking\n\n[![Build](https://github.com/smol-rs/parking/workflows/Build%20and%20test/badge.svg)](\nhttps://github.com/smol-rs/parking/actions)\n[![License](https://img.shields.io/badge/license-Apache--2.0_OR_MIT-blue.svg)](\nhttps://github.com/smol-rs/parking)\n[![Cargo](https://img.shields.io/crates/v/parking.svg)](\nhttps://crates.io/crates/parking)\n[![Documentation](https://docs.rs/parking/badge.svg)](\nhttps://docs.rs/parking)\n\nThread parking and unparking.\n\nA `Parker` is in either the notified or unnotified state. The `park()` method blocks\nthe current thread until the `Parker` becomes notified and then puts it back into the unnotified\nstate. The `unpark()` method puts it into the notified state.\n\nThis API is similar to [`thread::park()`] and [`Thread::unpark()`] from the standard library.\nThe difference is that the state \"token\" managed by those functions is shared across an entire\nthread, and anyone can call [`thread::current()`] to access it. If you use `park` and `unpark`,\nbut you also call a function that uses `park` and `unpark` internally, that function could\ncause a deadlock by consuming a wakeup that was intended for you. The `Parker` object in this\ncrate avoids that problem by managing its own state, which isn't shared with unrelated callers.\n\n[`thread::park()`]: https://doc.rust-lang.org/std/thread/fn.park.html\n[`Thread::unpark()`]: https://doc.rust-lang.org/std/thread/struct.Thread.html#method.unpark\n[`thread::current()`]: https://doc.rust-lang.org/std/thread/fn.current.html\n\n## Examples\n\n```rust\nuse std::thread;\nuse std::time::Duration;\nuse parking::Parker;\n\nlet p = Parker::new();\nlet u = p.unparker();\n\n// Notify the parker.\nu.unpark();\n\n// Wakes up immediately because the parker is notified.\np.park();\n\nthread::spawn(move || {\n    thread::sleep(Duration::from_millis(500));\n    u.unpark();\n});\n\n// Wakes up when `u.unpark()` notifies and then goes back into unnotified state.\np.park();\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\ndual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmol-rs%2Fparking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmol-rs%2Fparking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmol-rs%2Fparking/lists"}