Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f452755

Browse files
Annotate sync functions
1 parent 96ba61a commit f452755

File tree

18 files changed

+64
-64
lines changed

18 files changed

+64
-64
lines changed

‎04_safe_globals/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ diff -uNr 03_hacky_hello_world/src/synchronization.rs 04_safe_globals/src/synchr
313313
+ type Data;
314314
+
315315
+ /// Locks the mutex and grants the closure temporary mutable access to the wrapped data.
316-
+ fn lock<R>(&self, f: impl FnOnce(&mut Self::Data) -> R) -> R;
316+
+ fn lock<'a, R>(&'a self, f: impl FnOnce(&'a mut Self::Data) -> R) -> R;
317317
+ }
318318
+}
319319
+
@@ -354,7 +354,7 @@ diff -uNr 03_hacky_hello_world/src/synchronization.rs 04_safe_globals/src/synchr
354354
+impl<T> interface::Mutex for NullLock<T> {
355355
+ type Data = T;
356356
+
357-
+ fn lock<R>(&self, f: impl FnOnce(&mut Self::Data) -> R) -> R {
357+
+ fn lock<'a, R>(&'a self, f: impl FnOnce(&'a mut Self::Data) -> R) -> R {
358358
+ // In a real lock, there would be code encapsulating this line that ensures that this
359359
+ // mutable reference will ever only be given out once at a time.
360360
+ let data = unsafe { &mut *self.data.get() };

‎04_safe_globals/src/synchronization.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub mod interface {
2626
type Data;
2727

2828
/// Locks the mutex and grants the closure temporary mutable access to the wrapped data.
29-
fn lock<R>(&self, f: impl FnOnce(&mut Self::Data) -> R) -> R;
29+
fn lock<'a,R>(&'aself, f: impl FnOnce(&'amut Self::Data) -> R) -> R;
3030
}
3131
}
3232

@@ -67,7 +67,7 @@ impl<T> NullLock<T> {
6767
impl<T> interface::Mutex for NullLock<T> {
6868
type Data = T;
6969

70-
fn lock<R>(&self, f: impl FnOnce(&mut Self::Data) -> R) -> R {
70+
fn lock<'a,R>(&'aself, f: impl FnOnce(&'amut Self::Data) -> R) -> R {
7171
// In a real lock, there would be code encapsulating this line that ensures that this
7272
// mutable reference will ever only be given out once at a time.
7373
let data = unsafe { &mut *self.data.get() };

‎05_drivers_gpio_uart/src/synchronization.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub mod interface {
2626
type Data;
2727

2828
/// Locks the mutex and grants the closure temporary mutable access to the wrapped data.
29-
fn lock<R>(&self, f: impl FnOnce(&mut Self::Data) -> R) -> R;
29+
fn lock<'a,R>(&'aself, f: impl FnOnce(&'amut Self::Data) -> R) -> R;
3030
}
3131
}
3232

@@ -67,7 +67,7 @@ impl<T> NullLock<T> {
6767
impl<T> interface::Mutex for NullLock<T> {
6868
type Data = T;
6969

70-
fn lock<R>(&self, f: impl FnOnce(&mut Self::Data) -> R) -> R {
70+
fn lock<'a,R>(&'aself, f: impl FnOnce(&'amut Self::Data) -> R) -> R {
7171
// In a real lock, there would be code encapsulating this line that ensures that this
7272
// mutable reference will ever only be given out once at a time.
7373
let data = unsafe { &mut *self.data.get() };

‎06_uart_chainloader/src/synchronization.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub mod interface {
2626
type Data;
2727

2828
/// Locks the mutex and grants the closure temporary mutable access to the wrapped data.
29-
fn lock<R>(&self, f: impl FnOnce(&mut Self::Data) -> R) -> R;
29+
fn lock<'a,R>(&'aself, f: impl FnOnce(&'amut Self::Data) -> R) -> R;
3030
}
3131
}
3232

@@ -67,7 +67,7 @@ impl<T> NullLock<T> {
6767
impl<T> interface::Mutex for NullLock<T> {
6868
type Data = T;
6969

70-
fn lock<R>(&self, f: impl FnOnce(&mut Self::Data) -> R) -> R {
70+
fn lock<'a,R>(&'aself, f: impl FnOnce(&'amut Self::Data) -> R) -> R {
7171
// In a real lock, there would be code encapsulating this line that ensures that this
7272
// mutable reference will ever only be given out once at a time.
7373
let data = unsafe { &mut *self.data.get() };

‎07_timestamps/src/synchronization.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub mod interface {
2626
type Data;
2727

2828
/// Locks the mutex and grants the closure temporary mutable access to the wrapped data.
29-
fn lock<R>(&self, f: impl FnOnce(&mut Self::Data) -> R) -> R;
29+
fn lock<'a,R>(&'aself, f: impl FnOnce(&'amut Self::Data) -> R) -> R;
3030
}
3131
}
3232

@@ -67,7 +67,7 @@ impl<T> NullLock<T> {
6767
impl<T> interface::Mutex for NullLock<T> {
6868
type Data = T;
6969

70-
fn lock<R>(&self, f: impl FnOnce(&mut Self::Data) -> R) -> R {
70+
fn lock<'a,R>(&'aself, f: impl FnOnce(&'amut Self::Data) -> R) -> R {
7171
// In a real lock, there would be code encapsulating this line that ensures that this
7272
// mutable reference will ever only be given out once at a time.
7373
let data = unsafe { &mut *self.data.get() };

‎08_hw_debug_JTAG/src/synchronization.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub mod interface {
2626
type Data;
2727

2828
/// Locks the mutex and grants the closure temporary mutable access to the wrapped data.
29-
fn lock<R>(&self, f: impl FnOnce(&mut Self::Data) -> R) -> R;
29+
fn lock<'a,R>(&'aself, f: impl FnOnce(&'amut Self::Data) -> R) -> R;
3030
}
3131
}
3232

@@ -67,7 +67,7 @@ impl<T> NullLock<T> {
6767
impl<T> interface::Mutex for NullLock<T> {
6868
type Data = T;
6969

70-
fn lock<R>(&self, f: impl FnOnce(&mut Self::Data) -> R) -> R {
70+
fn lock<'a,R>(&'aself, f: impl FnOnce(&'amut Self::Data) -> R) -> R {
7171
// In a real lock, there would be code encapsulating this line that ensures that this
7272
// mutable reference will ever only be given out once at a time.
7373
let data = unsafe { &mut *self.data.get() };

‎09_privilege_level/src/synchronization.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub mod interface {
2626
type Data;
2727

2828
/// Locks the mutex and grants the closure temporary mutable access to the wrapped data.
29-
fn lock<R>(&self, f: impl FnOnce(&mut Self::Data) -> R) -> R;
29+
fn lock<'a,R>(&'aself, f: impl FnOnce(&'amut Self::Data) -> R) -> R;
3030
}
3131
}
3232

@@ -67,7 +67,7 @@ impl<T> NullLock<T> {
6767
impl<T> interface::Mutex for NullLock<T> {
6868
type Data = T;
6969

70-
fn lock<R>(&self, f: impl FnOnce(&mut Self::Data) -> R) -> R {
70+
fn lock<'a,R>(&'aself, f: impl FnOnce(&'amut Self::Data) -> R) -> R {
7171
// In a real lock, there would be code encapsulating this line that ensures that this
7272
// mutable reference will ever only be given out once at a time.
7373
let data = unsafe { &mut *self.data.get() };

‎10_virtual_mem_part1_identity_mapping/src/synchronization.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub mod interface {
2626
type Data;
2727

2828
/// Locks the mutex and grants the closure temporary mutable access to the wrapped data.
29-
fn lock<R>(&self, f: impl FnOnce(&mut Self::Data) -> R) -> R;
29+
fn lock<'a,R>(&'aself, f: impl FnOnce(&'amut Self::Data) -> R) -> R;
3030
}
3131
}
3232

@@ -67,7 +67,7 @@ impl<T> NullLock<T> {
6767
impl<T> interface::Mutex for NullLock<T> {
6868
type Data = T;
6969

70-
fn lock<R>(&self, f: impl FnOnce(&mut Self::Data) -> R) -> R {
70+
fn lock<'a,R>(&'aself, f: impl FnOnce(&'amut Self::Data) -> R) -> R {
7171
// In a real lock, there would be code encapsulating this line that ensures that this
7272
// mutable reference will ever only be given out once at a time.
7373
let data = unsafe { &mut *self.data.get() };

‎11_exceptions_part1_groundwork/src/synchronization.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub mod interface {
2626
type Data;
2727

2828
/// Locks the mutex and grants the closure temporary mutable access to the wrapped data.
29-
fn lock<R>(&self, f: impl FnOnce(&mut Self::Data) -> R) -> R;
29+
fn lock<'a,R>(&'aself, f: impl FnOnce(&'amut Self::Data) -> R) -> R;
3030
}
3131
}
3232

@@ -67,7 +67,7 @@ impl<T> NullLock<T> {
6767
impl<T> interface::Mutex for NullLock<T> {
6868
type Data = T;
6969

70-
fn lock<R>(&self, f: impl FnOnce(&mut Self::Data) -> R) -> R {
70+
fn lock<'a,R>(&'aself, f: impl FnOnce(&'amut Self::Data) -> R) -> R {
7171
// In a real lock, there would be code encapsulating this line that ensures that this
7272
// mutable reference will ever only be given out once at a time.
7373
let data = unsafe { &mut *self.data.get() };

‎12_integrated_testing/kernel/src/synchronization.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub mod interface {
2626
type Data;
2727

2828
/// Locks the mutex and grants the closure temporary mutable access to the wrapped data.
29-
fn lock<R>(&self, f: impl FnOnce(&mut Self::Data) -> R) -> R;
29+
fn lock<'a,R>(&'aself, f: impl FnOnce(&'amut Self::Data) -> R) -> R;
3030
}
3131
}
3232

@@ -67,7 +67,7 @@ impl<T> NullLock<T> {
6767
impl<T> interface::Mutex for NullLock<T> {
6868
type Data = T;
6969

70-
fn lock<R>(&self, f: impl FnOnce(&mut Self::Data) -> R) -> R {
70+
fn lock<'a,R>(&'aself, f: impl FnOnce(&'amut Self::Data) -> R) -> R {
7171
// In a real lock, there would be code encapsulating this line that ensures that this
7272
// mutable reference will ever only be given out once at a time.
7373
let data = unsafe { &mut *self.data.get() };

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /