Amanieu / parking_lot

Compact and efficient synchronization primitives for Rust. Also provides an API for creating custom synchronization primitives.
Apache License 2.0
2.76k stars 217 forks source link

Allow unsafe creation of new lock guards #403

Closed Lochlanna closed 1 year ago

Lochlanna commented 1 year ago

This PR changes the visibility of the functions that produce the lock guards to public. The inspiration for this comes from my desire to extend the mutex with new locking functions (async locking for example).

I was initially concerned that exposing this might be a bad idea even if it is useful. However, I decided that exposing these functions was no worse than the already public force_unlock functions.

Amanieu commented 1 year ago

Could you rename these functions to make_guard_unchecked so that it's clear that these functions are unsafe and that you should carefully read the documentation for them?

Amanieu commented 1 year ago

Slight nit: could you rename the arc versions to make_arc(_read/write/upgradable)_guard?

After that it should be good to merge and I will publish a release to address #406

Amanieu commented 1 year ago

Thanks!