Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> It describes the algorithm but not how a caller of the Rust `parking_lot` crate could take advantage of this.

Read the WebKit post.

> By "just use parking_lot directly", I think you're talking about reimplementing the parking lot algorithm or using the C++ `WTF::ParkingLot` implementation? But not actually using the existing Rust crate called `parking_lot` described in the cuongle.dev article?

See https://docs.rs/parking_lot_core/latest/parking_lot_core/

That's my ParkingLot API. You can use it to implement many kinds of locks, including:

- Efficient ones that use a tristate, like the glibc lowlevellock, or what I call the Cascade lock. So, this doesn't even need two bits.

- The lock algorithm I prefer, which uses two bits.

- Lots of other algorithms. You can do very efficient condition variables, rwlocks, counting locks, etc.

You can do a lot of useful algorithms with fewer than 8 bits. You don't have to use the C++ ParkingLot. You don't have to implement parking_lot.

What you do have to do is RTFM



> Read the WebKit post.

Clearly I have already.

> See https://docs.rs/parking_lot_core/latest/parking_lot_core/ ... That's my ParkingLot API.

"just use parking_lot directly" is a weird way to say "use the `parking_lot_core` crate instead of the `parking_lot` crate".

...and note that I mentioned this in my earlier comment: (slightly more realistically, you could probably use the `parking_lot_core::park` portion of the implementation and build your own equivalent of `parking_lot::RawMutex` on top of it)

I'm not trying to be disagreeable here, but really you could save a lot of trouble if you were a bit more careful in your communication.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: