#async #sync #mutex #result #condvar

no-std rusturnate

A sync or async mutex, with or without timeouts

7 releases

new 0.0.7 May 12, 2024
0.0.6 May 9, 2024
0.0.5 Apr 28, 2024

#3 in #result

Download history 192/week @ 2024-04-14 227/week @ 2024-04-21 304/week @ 2024-04-28 128/week @ 2024-05-05

851 downloads per month

MIT/Apache

77KB
2K SLoC

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.

Dependencies

~325–800KB
~19K SLoC