summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMica White <botahamec@outlook.com>2024-03-11 16:33:26 -0400
committerMica White <botahamec@outlook.com>2024-03-11 16:33:26 -0400
commit462fc2d9aab8f0cba680caec344e4c388e9901b1 (patch)
tree6b401c5ed4920c2ec8093d5c49976fe0b72573c2 /examples
parent5eaa4fe1d3bfcda696122ba3d6b4914dba19ef96 (diff)
Documentation
Diffstat (limited to 'examples')
-rw-r--r--examples/basic.rs4
-rw-r--r--examples/dining_philosophers.rs2
-rw-r--r--examples/double_mutex.rs4
-rw-r--r--examples/list.rs4
4 files changed, 7 insertions, 7 deletions
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 {