diff options
| author | Mica White <botahamec@outlook.com> | 2024-03-09 16:53:12 -0500 |
|---|---|---|
| committer | Mica White <botahamec@outlook.com> | 2024-03-09 16:53:12 -0500 |
| commit | 6a54884b292987fc1371bf062c42e964b6a4b0fe (patch) | |
| tree | 7b4c20c4150522b0d6d8e3f5db8fbe17eb80abc5 /examples/double_mutex.rs | |
| parent | 8ea16a606bfcc1ba535f6cef3cb4c162f91d2eb0 (diff) | |
Pointer checks
Diffstat (limited to 'examples/double_mutex.rs')
| -rw-r--r-- | examples/double_mutex.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/examples/double_mutex.rs b/examples/double_mutex.rs index d1a939c..df11b7a 100644 --- a/examples/double_mutex.rs +++ b/examples/double_mutex.rs @@ -1,6 +1,6 @@ use std::thread; -use happylock::{LockGuard, Mutex, ThreadKey}; +use happylock::{LockCollection, Mutex, ThreadKey}; const N: usize = 10; @@ -13,7 +13,8 @@ fn main() { let th = thread::spawn(move || { let key = ThreadKey::lock().unwrap(); let data = (&DATA_1, &DATA_2); - let mut guard = LockGuard::lock(&data, key); + let lock = LockCollection::new(data).unwrap(); + let mut guard = lock.lock(key); *guard.1 = (100 - *guard.0).to_string(); *guard.0 += 1; }); @@ -26,7 +27,8 @@ fn main() { let key = ThreadKey::lock().unwrap(); let data = (&DATA_1, &DATA_2); - let data = LockGuard::lock(&data, key); + let data = LockCollection::new(data).unwrap(); + let data = data.lock(key); println!("{}", *data.0); println!("{}", *data.1); } |
