-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace std synchronization primitives with parking_lot #210
Replace std synchronization primitives with parking_lot #210
Conversation
I'm definitely into the simpler api. I need to do a bit of research into the parking lot Mutex impl, but on paper I like this a lot! |
The parking_lot crate is essentially a reimplementation of the WTF Webkit locking library in rust. These libraries reimplement locks as sort of userspace futexes, where there's a global hashmap of address -> lock metastate. In most cases, when there is little contention, the lock just performs an atomic operation on the byte (or word in the case of a RwLock) contained inside it, so performance is very good. In cases of contention, the lock looks up its associated data in the global hashmap and can add itself as a sleeping thread to it. |
This looks good to go as soon as conflicts are resolved. |
e80b316
to
ff4d9a8
Compare
@cart Alright, I think this should be good. |
* Replace std::sync::Mutex with parking_lot::Mutex * Replace std::sync::RwLock with parking_lot::RwLock
parking_lot:0.10.2
is already in the dependency tree, so this shouldn't add any compile-time.parking_lot::Mutex
is smaller, generally much faster, and has a more ergonomic api thanstd::sync::Mutex
. Same withRwLock
.