Skip to content

Commit 1059d24

Browse files
author
Stjepan Glavina
committed
Update readme
1 parent 8f2f43f commit 1059d24

File tree

1 file changed

+8
-43
lines changed

1 file changed

+8
-43
lines changed

README.md

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,13 @@
1-
# async-lock
1+
# async-io
22

3-
[![Build](https://github.com/stjepang/async-lock/workflows/Build%20and%20test/badge.svg)](
4-
https://github.com/stjepang/async-lock/actions)
3+
[![Build](https://github.com/stjepang/async-io/workflows/Build%20and%20test/badge.svg)](
4+
https://github.com/stjepang/async-io/actions)
55
[![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)](
6-
https://github.com/stjepang/async-lock)
7-
[![Cargo](https://img.shields.io/crates/v/async-lock.svg)](
8-
https://crates.io/crates/async-lock)
9-
[![Documentation](https://docs.rs/async-lock/badge.svg)](
10-
https://docs.rs/async-lock)
11-
12-
Reference-counted async lock.
13-
14-
The `Lock` type is similar to `std::sync::Mutex`, except locking is an async operation.
15-
16-
Note that `Lock` by itself acts like an `Arc` in the sense that cloning it returns just
17-
another reference to the same lock.
18-
19-
Furthermore, `LockGuard` is not tied to `Lock` by a lifetime, so you can keep guards for
20-
as long as you want. This is useful when you want to spawn a task and move a guard into its
21-
future.
22-
23-
The locking mechanism uses eventual fairness to ensure locking will be fair on average without
24-
sacrificing performance. This is done by forcing a fair lock whenever a lock operation is
25-
starved for longer than 0.5 milliseconds.
26-
27-
## Examples
28-
29-
```rust
30-
use async_lock::Lock;
31-
use smol::Task;
32-
33-
let lock = Lock::new(0);
34-
let mut tasks = vec![];
35-
36-
for _ in 0..10 {
37-
let lock = lock.clone();
38-
tasks.push(Task::spawn(async move { *lock.lock().await += 1 }));
39-
}
40-
41-
for task in tasks {
42-
task.await;
43-
}
44-
assert_eq!(*lock.lock().await, 10);
45-
```
6+
https://github.com/stjepang/async-io)
7+
[![Cargo](https://img.shields.io/crates/v/async-io.svg)](
8+
https://crates.io/crates/async-io)
9+
[![Documentation](https://docs.rs/async-io/badge.svg)](
10+
https://docs.rs/async-io)
4611

4712
## License
4813

0 commit comments

Comments
 (0)