From 619efed28b64858016c9a3a5b0f425f3e32e076e Mon Sep 17 00:00:00 2001 From: Kevin Leimkuhler Date: Mon, 3 Jun 2019 11:12:28 -0700 Subject: [PATCH] sync: Add Sync impl for Lock (#1116) Signed-off-by: Kevin Leimkuhler --- tokio-sync/src/lock.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tokio-sync/src/lock.rs b/tokio-sync/src/lock.rs index 017af197c..3cfa1beb2 100644 --- a/tokio-sync/src/lock.rs +++ b/tokio-sync/src/lock.rs @@ -69,9 +69,11 @@ pub struct Lock { #[derive(Debug)] pub struct LockGuard(Lock); -// As long as T: Send, it's fine to send Lock to other threads. -// If T was not Send, sending a Lock would be bad, since you can access T through Lock. +// As long as T: Send, it's fine to send and share Lock between threads. +// If T was not Send, sending and sharing a Lock would be bad, since you can access T through +// Lock. unsafe impl Send for Lock where T: Send {} +unsafe impl Sync for Lock where T: Send {} unsafe impl Sync for LockGuard where T: Send + Sync {} #[derive(Debug)]