Amanieu / parking_lot

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

Remove `windows-sys` dependency #374

Closed Jake-Shadle closed 1 year ago

Jake-Shadle commented 1 year ago

This replaces the windows-sys dependency with manual bindings to only the functions, types, and constants needed by parking_lot.

Rationale

parking_lot is a foundational dependency, and thus its choice of dependencies has a fairly wide effect on the ecosystem since it's almost inevitable that even a moderately sized dependency graph will pull it in. This is particularly true due the problematic issue I pointed out in https://github.com/microsoft/windows-rs/issues/1720, in which I actually used parking_lot as an example due to its foundational nature. Using bindings in the few places they are needed means we can completely get rid of the windows-sys dependency, positively impacting a huge part of the crates ecosystem with no negatives.

  1. Win32 functions/types/constants will never change, there is no reason to use an external crate of bindings
  2. parking_lot_core already has manual bindings to Nt* functions since they are not officially supported by Microsoft and thus not part of the Win32 metadata used to generate the windows-sys bindings.

See #332 for a related open issue, and https://github.com/Amanieu/parking_lot/pull/334#issuecomment-1083340661

kennykerr commented 1 year ago

Reminder to adopt standalone code generation support as this PR alone leaves you vulnerable to linker issues.