Amanieu / parking_lot

Compact and efficient synchronization primitives for Rust. Also provides an API for creating custom synchronization primitives.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Weird error when passing guards to another thread

Ved-s opened this issue · comments



Guards implement Send for some reason?

parking_lot's RwLockWriteGuard implements Send when the protected value implements it.

The error message with std is nicer because it uses an unstable feature to directly implement !Send on mutex guards. parking_lot uses a different method (see GuardNoSend) which effectively has the same effect.

what was the reason of doing that instead of !Send ?

impl !Send for Type {} is unstable, so parking_lot can't use it. The standard library is privileged in that it can use any unstable feature even on stable rustc.

Makes sense, though I've seen parking_lot use impl !Sync (ig it's stable?)