mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-25 12:00:35 +00:00
sync: Add Sync impl for Lock (#1116)
Signed-off-by: Kevin Leimkuhler <kevin@kleimkuhler.com>
This commit is contained in:
parent
18ed0be851
commit
619efed28b
@ -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)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user