{"id":13625968,"url":"https://github.com/kprotty/usync","last_synced_at":"2025-04-04T16:17:12.836Z","repository":{"id":39649655,"uuid":"304150479","full_name":"kprotty/usync","owner":"kprotty","description":"Small, fast, synchronization primitives","archived":false,"fork":false,"pushed_at":"2023-04-24T21:43:43.000Z","size":278,"stargazers_count":230,"open_issues_count":1,"forks_count":9,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-26T05:05:07.634Z","etag":null,"topics":["concurrency","rust","threading"],"latest_commit_sha":null,"homepage":"","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/kprotty.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-10-14T22:30:42.000Z","updated_at":"2024-04-23T12:49:02.000Z","dependencies_parsed_at":"2024-01-14T07:04:11.967Z","dependency_job_id":"8b6b566a-421f-4cd3-a90e-c403b2e6f917","html_url":"https://github.com/kprotty/usync","commit_stats":{"total_commits":72,"total_committers":8,"mean_commits":9.0,"dds":0.4305555555555556,"last_synced_commit":"8937bb77963f6bf9068e56ad46133e933eb79974"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kprotty%2Fusync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kprotty%2Fusync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kprotty%2Fusync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kprotty%2Fusync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kprotty","download_url":"https://codeload.github.com/kprotty/usync/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247208190,"owners_count":20901570,"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":["concurrency","rust","threading"],"created_at":"2024-08-01T21:02:06.744Z","updated_at":"2025-04-04T16:17:12.810Z","avatar_url":"https://github.com/kprotty.png","language":"Rust","readme":"usync\n============\n\n[![Crates.io](https://img.shields.io/crates/v/usync.svg)](https://crates.io/crates/usync)\n[![Documentation](https://docs.rs/usync/badge.svg)](https://docs.rs/usync/)\n[![MSRV: 1.59.0](https://flat.badgen.net/badge/MSRV/1.59.0/purple)](https://blog.rust-lang.org/2022/02/24/Rust-1.59.0.html)\n\nThis library provides implementations of `Mutex`, `RwLock`, `Condvar`, `Barrier` and\n`Once` that are word-sized and generally fast as those in [`parking_lot`](https://crates.io/crates/parking_lot).\nIt also provides a `ReentrantMutex` type which supports recursive locking. \n\n## Features\n\nThe primitives provided by this library have several advantages over those\nin the Rust standard library:\n\n1. All types require only 1 word of storage (unlike stdlib which stores\n   more state for poison detection).\n2. Inline uncontested paths and micro-contention handled with bounded,\n   adaptive spinning.\n3. `Condvar::notify_all` will generally only wake up a single thread and requeue the\n    rest to wait on the associated `Mutex`. This avoids a thundering herd\n    problem where all threads try to acquire the lock at the same time.\n4. `Mutex` and `RwLock` allow raw locking and unlocking without a RAII guard object.\n5. A `ReentrantMutex` type which supports recursive locking.\n6. Lock guards can be sent to other threads when the `send_guard` feature is\n    enabled.\n\n## Userspace queues\n\nTo keep these primitives word sized, their state is multiplexed between \ncounters, queues of threads, and combinations of both. This draws similarities\nto Windows' [Slim Synchronization Primitives](https://docs.microsoft.com/en-us/archive/msdn-magazine/2007/june/concurrency-synchronization-primitives-new-to-windows-vista). No external locking\nof global queues as seen in Linux futex or parking_lot is employed. The queues are all\nembedded in each primitive and interacted with lock-free operations to decrease worst-case contention latency.\n\nHaving to juggle around queues with the synchronization state unfortunately means\nthat \"no spurious wakeups\" cannot be guaranteed for `Condvar` and that extreme read-only workflows\nfor `RwLock` can't use optimized atomics to improve throughput. These perf limits shouldn't matter\nin practice though, even more so when other cache effects come into play. On the bright side, \nwriter/exclusive heavy workloads scale much better than existing solutions and are heavily\noptimized for micro-contention.\n\n## Nightly vs stable\n\nThere are a few restrictions when using this library on stable Rust:\n\n- You will have to use the `const_*` functions (e.g. `const_mutex(val)`) to\n  statically initialize the locking primitives. Using e.g. `Mutex::new(val)`\n  does not work on stable Rust yet.\n\nTo enable nightly-only functionality, you need to enable the `nightly` feature\nin Cargo (see below).\n\n## Usage\n\nAdd this to your `Cargo.toml`:\n\n```toml\n[dependencies]\nusync = \"0.2.1\"\n```\n\nTo enable nightly-only features, add this to your `Cargo.toml` instead:\n\n```toml\n[dependencies]\nusync = { version = \"0.2.1\", features = [\"nightly\"] }\n```\n\nTo allow sending `MutexGuard`s and `RwLock*Guard`s to other threads, enable the\n`send_guard` option.\n\n## License\n\nLicensed under MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT).\n","funding_links":[],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkprotty%2Fusync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkprotty%2Fusync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkprotty%2Fusync/lists"}