sync: Add Sync impl for Lock (#1116)

Signed-off-by: Kevin Leimkuhler <kevin@kleimkuhler.com>
This commit is contained in:
Kevin Leimkuhler 2019-06-03 11:12:28 -07:00 committed by Carl Lerche
parent 18ed0be851
commit 619efed28b

View File

@ -69,9 +69,11 @@ pub struct Lock<T> {
#[derive(Debug)]
pub struct LockGuard<T>(Lock<T>);
// As long as T: Send, it's fine to send Lock<T> to other threads.
// If T was not Send, sending a Lock<T> would be bad, since you can access T through Lock<T>.
// As long as T: Send, it's fine to send and share Lock<T> between threads.
// If T was not Send, sending and sharing a Lock<T> would be bad, since you can access T through
// Lock<T>.
unsafe impl<T> Send for Lock<T> where T: Send {}
unsafe impl<T> Sync for Lock<T> where T: Send {}
unsafe impl<T> Sync for LockGuard<T> where T: Send + Sync {}
#[derive(Debug)]