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

Use macros to reduce code deduplication #358

Closed notgull closed 2 years ago

notgull commented 2 years ago

In #291, I added Arc-oriented Mutex locks; however, when writing the locking functions for this code, there is a lot of code that ends up being duplicated. This PR adds a macro that reduces the amount of code written (and may make it easier to add more Arc-oriented methods in the future.

I'm not particularly attached to any kind of macro syntax.

Amanieu commented 2 years ago

I'm not a big fan of this change. I think it makes maintenance harder because the code is now much less readable and it isn't formatted by rustfmt.

notgull commented 2 years ago

Fair enough.