diff options
| author | Mica White <botahamec@outlook.com> | 2024-03-08 12:18:41 -0500 |
|---|---|---|
| committer | Mica White <botahamec@outlook.com> | 2024-03-08 12:18:41 -0500 |
| commit | 03d0cdb7145042ce51c9eb98bfd081a4f10fe8e1 (patch) | |
| tree | 0d2b753760194661a5a5a8f2bfd60a822e116c47 /examples/double_mutex.rs | |
| parent | 6b6f207965cc71fa9a7a056a1c89675116abec74 (diff) | |
Keyable
Diffstat (limited to 'examples/double_mutex.rs')
| -rw-r--r-- | examples/double_mutex.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/examples/double_mutex.rs b/examples/double_mutex.rs index 033bfed..18460e4 100644 --- a/examples/double_mutex.rs +++ b/examples/double_mutex.rs @@ -11,17 +11,17 @@ static DATA_2: SpinLock<String> = Mutex::new(String::new()); fn main() { for _ in 0..N { thread::spawn(move || { - let mut key = ThreadKey::lock().unwrap(); + let key = ThreadKey::lock().unwrap(); let data = (&DATA_1, &DATA_2); - let mut guard = LockGuard::lock(&data, &mut key); + let mut guard = LockGuard::lock(&data, key); *guard.1 = (100 - *guard.0).to_string(); *guard.0 += 1; }); } - let mut key = ThreadKey::lock().unwrap(); + let key = ThreadKey::lock().unwrap(); let data = (&DATA_1, &DATA_2); - let data = LockGuard::lock(&data, &mut key); + let data = LockGuard::lock(&data, key); println!("{}", *data.0); println!("{}", *data.1); } |
