MutexGuard
impls both Sync
and !Send
.
I guess it is because poisoning is not allowed to happen on thread which is not the creator of the guard. Please correct me if I'm wrong, and if it's true, please tell me why this is not allowed. Thanks.
I recommend reading all of this:
The part about your specific question:
For a more realistic example, it turns out that
MutexGuard
is notSend
, since for the definition ofMutexGuard
to be maximally portable, it needs to support the POSIX API ofpthreads
, which states that a lock can only be released from within the thread where it was created.
7 Likes
Thanks, I got it.