File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,11 @@ impl<T> Mutex<T> {
19
19
pub fn borrow < ' cs > ( & self , _ctxt : & ' cs CriticalSection ) -> & ' cs T {
20
20
unsafe { & * self . inner . get ( ) }
21
21
}
22
+
23
+ /// Mutably borrows the data for the duration of the critical section
24
+ pub fn borrow_mut < ' cs > ( & self , _ctxt : & ' cs mut CriticalSection ) -> & ' cs mut T {
25
+ unsafe { & mut * self . inner . get ( ) }
26
+ }
22
27
}
23
28
24
29
/// Interrupt number
@@ -75,14 +80,14 @@ pub struct CriticalSection {
75
80
/// This as also known as a "critical section".
76
81
pub fn free < F , R > ( f : F ) -> R
77
82
where
78
- F : FnOnce ( & CriticalSection ) -> R ,
83
+ F : FnOnce ( CriticalSection ) -> R ,
79
84
{
80
85
let primask = :: register:: primask:: read ( ) ;
81
86
82
87
// disable interrupts
83
88
disable ( ) ;
84
89
85
- let r = f ( & CriticalSection { _0 : ( ) } ) ;
90
+ let r = f ( CriticalSection { _0 : ( ) } ) ;
86
91
87
92
// If the interrupts were active before our `disable` call, then re-enable
88
93
// them. Otherwise, keep them disabled
You can’t perform that action at this time.
0 commit comments