Skip to content

Commit 388689a

Browse files
committed
Add parking_lot README
1 parent 978c233 commit 388689a

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

wrappers/parking_lot/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Shuttle support for `parking_lot`
2+
3+
This folder contains the implementation and wrapper that enables testing of [parking_lot](https://crates.io/crates/parking_lot) applications with Shuttle.
4+
5+
## How to use
6+
7+
To use it, add the following in your Cargo.toml:
8+
9+
```
10+
[features]
11+
shuttle = [
12+
"parking_lot/shuttle",
13+
]
14+
15+
[dependencies]
16+
parking_lot = { package = "shuttle-parking_lot", version = "VERSION_NUMBER" }
17+
```
18+
19+
The code will then behave as before when the `shuttle` feature flag is not provided, and will run with Shuttle-compatible primitives when the `shuttle` feature flag is provided.
20+
21+
## Limitations
22+
23+
Shuttle's parking_lot functionality is currently limited to a subset of the `Mutex` and `RwLock` primitives. If your project needs functionality which is not currently supported, please file an issue or, better yet, open a PR to contribute the functionality.

wrappers/parking_lot/parking_lot_impl/src/rwlock.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,11 @@ impl<T> RwLock<T> {
3232
/// Creates a new instance of an `RwLock<T>` which is unlocked
3333
/// and allows a maximum of `max_readers` concurrent readers.
3434
const fn with_max_readers(value: T, max_readers: usize) -> Self {
35-
let sem = BatchSemaphore::const_new(max_readers, Fairness::StrictlyFair);
36-
let rwlock = RwLock {
35+
RwLock {
3736
max_readers,
38-
sem,
37+
sem: BatchSemaphore::const_new(max_readers, Fairness::StrictlyFair),
3938
inner: UnsafeCell::new(value),
40-
};
41-
rwlock
39+
}
4240
}
4341
}
4442

0 commit comments

Comments
 (0)