jonhoo / guardian

Owned mutex guards for refcounted mutexes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

guardian for parking_lot's sync primitives?

dashed opened this issue · comments

I did a _naive_ refactor of guardian for parking_lot's sync primitives on a personal branch:
dashed@3e756e8


I'm wondering if there may be interest to have guardian support parking_lot's sync primitives. I'm unsure what support would look like for both rust's sync primitives and parking_lot's sync primitives.

I'm hesitant to add this because it would also add a dependency on parking_lot. It could be made optional as a feature, but that complicates using the crate. It's not particularly difficult though. The main reason for the size of your diff is that you import Arc directly instead of using sync::Arc. Adding parking_lot should mostly be a matter of adding additional wrapper types (analogous to the sync::* ones), implementing take, and writing tests.

parking_lot, no doubt, shouldn't be a hard dependency; it totally should be an optional feature 👍

Adding support for parking_lot definitely does add complexity to this crate, and I even was thinking of just having a separate crate to keep things simple (e.g. guardian-parking_lot); but I wanted to run the idea of parking_lot support by you first.


I don't have a particular immediate demand for guardian crate to support parking_lot.

Feel free to close this issue if you do decide this crate shouldn't support parking_lot; otoh, if left open, I may look into what the wrapper types look like when I get around to it (unless you or someone else does/claims it first 😄 ).

Yeah, I think a separate package is probably the best solution. Maybe simply as a fork of this repo so it's easy to sync changes? I think the changes should be fairly minimal; basically just substitute the sync:: locks with the parking_lot ones, and get rid of the LockResult stuff, since parking_lot doesn't have them.

Thanks for the heads up 👍. I'll look into creating a separate crate i.e. guardian-parking_lot.

At the moment, I'm primarily using guardian for my use cases which is working quite well. I haven't committed a switch to guardian-parking_lot just yet; I definitely like to keep this option open.