From 970f75f830e4888f33bc65bad80f11457be5dd51 Mon Sep 17 00:00:00 2001 From: Kevin Leimkuhler Date: Tue, 4 Jun 2019 17:04:35 -0700 Subject: [PATCH] sync: Add Sync impl for Lock (#1117) --- 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 b6153800f..2f8b32f88 100644 --- a/tokio-sync/src/lock.rs +++ b/tokio-sync/src/lock.rs @@ -72,9 +72,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)]