From 462fc2d9aab8f0cba680caec344e4c388e9901b1 Mon Sep 17 00:00:00 2001 From: Mica White Date: Mon, 11 Mar 2024 16:33:26 -0400 Subject: Documentation --- examples/basic.rs | 4 ++-- examples/dining_philosophers.rs | 2 +- examples/double_mutex.rs | 4 ++-- examples/list.rs | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'examples') diff --git a/examples/basic.rs b/examples/basic.rs index 8842e16..1d611d3 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -10,7 +10,7 @@ fn main() { let mut threads = Vec::new(); for _ in 0..N { let th = thread::spawn(move || { - let key = ThreadKey::lock().unwrap(); + let key = ThreadKey::get().unwrap(); let mut data = DATA.lock(key); *data += 1; }); @@ -21,7 +21,7 @@ fn main() { _ = th.join(); } - let key = ThreadKey::lock().unwrap(); + let key = ThreadKey::get().unwrap(); let data = DATA.lock(key); println!("{}", *data); } diff --git a/examples/dining_philosophers.rs b/examples/dining_philosophers.rs index f8657df..35aa330 100644 --- a/examples/dining_philosophers.rs +++ b/examples/dining_philosophers.rs @@ -46,7 +46,7 @@ struct Philosopher { impl Philosopher { fn cycle(&self) { - let key = ThreadKey::lock().unwrap(); + let key = ThreadKey::get().unwrap(); thread::sleep(Duration::from_secs(1)); // safety: no philosopher asks for the same fork twice diff --git a/examples/double_mutex.rs b/examples/double_mutex.rs index 320f461..621f81e 100644 --- a/examples/double_mutex.rs +++ b/examples/double_mutex.rs @@ -10,7 +10,7 @@ fn main() { let mut threads = Vec::new(); for _ in 0..N { let th = thread::spawn(move || { - let key = ThreadKey::lock().unwrap(); + let key = ThreadKey::get().unwrap(); let lock = LockCollection::new_ref(&DATA); let mut guard = lock.lock(key); *guard.1 = (100 - *guard.0).to_string(); @@ -23,7 +23,7 @@ fn main() { _ = th.join(); } - let key = ThreadKey::lock().unwrap(); + let key = ThreadKey::get().unwrap(); let data = LockCollection::new_ref(&DATA); let data = data.lock(key); println!("{}", *data.0); diff --git a/examples/list.rs b/examples/list.rs index 14117ee..3b03f2d 100644 --- a/examples/list.rs +++ b/examples/list.rs @@ -29,7 +29,7 @@ fn main() { let mut threads = Vec::new(); for _ in 0..N { let th = thread::spawn(move || { - let mut key = ThreadKey::lock().unwrap(); + let mut key = ThreadKey::get().unwrap(); loop { let mut data = Vec::new(); for _ in 0..3 { @@ -55,7 +55,7 @@ fn main() { _ = th.join(); } - let key = ThreadKey::lock().unwrap(); + let key = ThreadKey::get().unwrap(); let data = LockCollection::new_ref(&DATA); let data = data.lock(key); for val in &*data { -- cgit v1.2.3