rusturnate

Crates.iorusturnate
lib.rsrusturnate
version0.0.9
sourcesrc
created_at2024-04-14 22:15:07.282412
updated_at2024-05-18 17:15:26.457192
descriptionA sync or async mutex, with or without timeouts.
homepage
repositoryhttps://gitlab.com/in2vd-open/rusturnate
max_upload_size
id1208578
size109,366
IntoVoid (in2vd)

documentation

README

rusturnate

crates.io documentation pipeline status

Overview

rusturnate introduces a cell-like object called a Rusturn, which may hold an arbitrary type. It can be shared across thread or future boundaries using Arc or static.

The Editor (MutexGuard)

Similar to std::sync::Mutex, a Rusturn allows only one thread or future to access its contents at a time by acquiring an Editor (similar to a MutexGuard). There can only be one editor instance accessing a Rusturn object at any given moment. To finish editing the editor must either be dropped or .done() must be invoked on it. Subsequently, other threads can acquire a new instance of an editor. If a panic occurs while holding an editor it gets marked as poisoned. Despite this, access is still possible. However, you will need to handle the resulting PoisonError and update the editorĀ“s value to clear its poisoned state. auto-poisoning only works if the std feature is enabled. Otherwise, you can do manual poisoning by activating the manual_poisoning or anytime_poisoning feature.

Manual poisoning

TODO

The Access object

TODO

Awaiting results

TODO

Feature flags

TODO

Use of unsafe

TODO

Allocation details

This crate itself does not perform any heap allocations. However, if the suspending_with_timeout feature is enabled, it utilizes the futures-timer crate, which does perform heap allocations. futures-timer is only used for suspending execution in an async context with a timeout.

Roadmap

  • Rusturn/Editor implementation
  • sync/async awaiting/queuing
  • sync/async timeouts
  • auto/manual poisoning
  • full README.md explanation
  • clear documentation for exposed methods
  • documentation for internal methods
  • explicit edge case tests
  • more debug assertions

License

Licensed under either of Apache License, Version 2.0 or MIT license.
Commit count: 78

cargo fmt