It is a lib which provide asynchronous locking mechanisms, which used spinlock algorithm. It's maybe very efficient because when mutex tries to acquire data unsuccessfully, these returning control to an async runtime back. This lib built only on atomics and don't use others std synchronous data structures, which make this lib so fast.
```rust use fastasyncmutex::mutex::Mutex;
async fn main() { let mutex = Mutex::new(10); let guard = mutex.lock().await; assert_eq!(*guard, 10); } ```
There is result of benchmarks which runs on MacBook Pro (16-inch, 2019) 2,3 GHz 8-Core Intel Core i9 16GB RAM
Tests you can find in the benchmarks dir.
```
running 35 tests
test mutex::fastasyncmutex::tests::concurrencywithoutwaiting ... bench: 1,655,316 ns/iter (+/- 130,153)
test mutex::fastasyncmutex::tests::create ... bench: 0 ns/iter (+/- 0)
test mutex::fastasyncmutex::tests::stepbystepwithoutwaiting ... bench: 209,525 ns/iter (+/- 41,279)
test mutex::fastasyncmutexordered::tests::concurrencywithoutwaiting ... bench: 1,658,499 ns/iter (+/- 227,813)
test mutex::fastasyncmutexordered::tests::create ... bench: 0 ns/iter (+/- 0)
test mutex::fastasyncmutexordered::tests::stepbystepwithoutwaiting ... bench: 228,778 ns/iter (+/- 57,589)
test mutex::futures::tests::concurrencywithoutwaiting ... bench: 1,717,780 ns/iter (+/- 339,007)
test mutex::futures::tests::create ... bench: 89 ns/iter (+/- 20)
test mutex::futures::tests::stepbystepwithoutwaiting ... bench: 208,992 ns/iter (+/- 39,132)
test mutex::smol::tests::concurrencywithoutwaiting ... bench: 1,898,404 ns/iter (+/- 205,293)
test mutex::smol::tests::create ... bench: 0 ns/iter (+/- 0)
test mutex::smol::tests::stepbystepwithoutwaiting ... bench: 337,008 ns/iter (+/- 42,071)
test mutex::tokio::tests::concurrencywithoutwaiting ... bench: 22,084,099 ns/iter (+/- 3,158,231)
test mutex::tokio::tests::create ... bench: 87 ns/iter (+/- 19)
test mutex::tokio::tests::stepbystepwithoutwaiting ... bench: 700,349 ns/iter (+/- 104,633)
test rwlock::fastasyncmutex::tests::concurrencyread ... bench: 1,706,870 ns/iter (+/- 162,620)
test rwlock::fastasyncmutex::tests::concurrencywrite ... bench: 1,580,081 ns/iter (+/- 277,137)
test rwlock::fastasyncmutex::tests::create ... bench: 0 ns/iter (+/- 0)
test rwlock::fastasyncmutex::tests::stepbystepread ... bench: 249,690 ns/iter (+/- 44,143)
test rwlock::fastasyncmutex::tests::stepbystepwriting ... bench: 173,125 ns/iter (+/- 31,013)
test rwlock::fastasyncmutexordered::tests::concurrencyread ... bench: 1,780,221 ns/iter (+/- 135,192)
test rwlock::fastasyncmutexordered::tests::concurrencywrite ... bench: 1,654,904 ns/iter (+/- 147,652)
test rwlock::fastasyncmutexordered::tests::create ... bench: 0 ns/iter (+/- 0)
test rwlock::fastasyncmutexordered::tests::stepbystepread ... bench: 323,291 ns/iter (+/- 63,657)
test rwlock::fastasyncmutexordered::tests::stepbystepwriting ... bench: 212,939 ns/iter (+/- 40,587)
test rwlock::smol::tests::concurrencyread ... bench: 1,686,007 ns/iter (+/- 448,853)
test rwlock::smol::tests::concurrencywrite ... bench: 2,115,666 ns/iter (+/- 178,394)
test rwlock::smol::tests::create ... bench: 1 ns/iter (+/- 0)
test rwlock::smol::tests::stepbystepread ... bench: 189,378 ns/iter (+/- 38,296)
test rwlock::smol::tests::stepbystepwriting ... bench: 592,654 ns/iter (+/- 149,131)
test rwlock::tokio::tests::concurrencyread ... bench: 23,426,186 ns/iter (+/- 2,685,113)
test rwlock::tokio::tests::concurrencywrite ... bench: 23,410,050 ns/iter (+/- 2,571,675)
test rwlock::tokio::tests::create ... bench: 87 ns/iter (+/- 17)
test rwlock::tokio::tests::stepbystepread ... bench: 850,208 ns/iter (+/- 237,666)
test rwlock::tokio::tests::stepbystepwriting ... bench: 805,490 ns/iter (+/- 115,358)
test result: ok. 0 passed; 0 failed; 0 ignored; 35 measured; 0 filtered out ```
Licensed under either of
at your option.
Unless 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.