aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <japaricious@gmail.com> 2017-04-19 16:35:07 -0500
committerGravatar Jorge Aparicio <japaricious@gmail.com> 2017-04-19 16:35:07 -0500
commit0827c40a265adc4ffc143e96ecb5627618b2f68e (patch)
tree54af4d6baccdcf54a345a4612561f58a66e1a0a9
parent914e19d6a5c4d7fd70dbee6a9b65c7ac2f6c7794 (diff)
downloadrtic-0827c40a265adc4ffc143e96ecb5627618b2f68e.tar.gz
rtic-0827c40a265adc4ffc143e96ecb5627618b2f68e.tar.zst
rtic-0827c40a265adc4ffc143e96ecb5627618b2f68e.zip
remove the _mut methods
they are too limited
-rw-r--r--src/lib.rs36
-rw-r--r--tests/cfail/claim_mut.rs34
2 files changed, 1 insertions, 69 deletions
diff --git a/src/lib.rs b/src/lib.rs
index eef735a9..eec40e44 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -17,7 +17,7 @@ use cortex_m::ctxt::Context;
use cortex_m::interrupt::Nr;
#[cfg(not(thumbv6m))]
use cortex_m::register::{basepri, basepri_max};
-use static_ref::{Ref, RefMut};
+use static_ref::Ref;
use typenum::{Cmp, Equal, Unsigned};
#[cfg(not(thumbv6m))]
use typenum::{Greater, Less};
@@ -87,18 +87,6 @@ impl<T, CEILING> Resource<T, C<CEILING>> {
unsafe { Ref::new(&*self.data.get()) }
}
- /// Like [Resource.claim](struct.Resource.html#method.claim) but returns a
- /// `&mut-` reference
- pub fn claim_mut<'task, PRIORITY>(
- &'static self,
- _priority: &'task mut P<PRIORITY>,
- ) -> RefMut<'task, T>
- where
- CEILING: Cmp<PRIORITY, Output = Equal>,
- {
- unsafe { RefMut::new(&mut *self.data.get()) }
- }
-
/// Locks the resource for the duration of the critical section `f`
///
/// For the duration of the critical section, tasks whose priority level is
@@ -124,28 +112,6 @@ impl<T, CEILING> Resource<T, C<CEILING>> {
ret
}
}
-
- /// Like [Resource.lock](struct.Resource.html#method.lock) but returns a
- /// `&mut-` reference
- ///
- /// This method has additional an additional constraint: you can't borrow a
- /// resource that has ceiling equal `CEILING`. This constraint is required
- /// to preserve Rust aliasing rules.
- #[cfg(not(thumbv6m))]
- pub fn lock_mut<R, PRIORITY, F>(&'static self, _priority: &mut P<PRIORITY>, f: F) -> R
- where F: FnOnce(RefMut<T>) -> R,
- CEILING: Cmp<PRIORITY, Output = Greater> + Cmp<UMAX, Output = Less> + Level
- {
- unsafe {
- let old_basepri = basepri::read();
- basepri_max::write(<CEILING>::hw());
- barrier!();
- let ret = f(RefMut::new(&mut *self.data.get()));
- barrier!();
- basepri::write(old_basepri);
- ret
- }
- }
}
unsafe impl<T, C> Sync for Resource<T, C>
diff --git a/tests/cfail/claim_mut.rs b/tests/cfail/claim_mut.rs
deleted file mode 100644
index 50da4a61..00000000
--- a/tests/cfail/claim_mut.rs
+++ /dev/null
@@ -1,34 +0,0 @@
-#![feature(const_fn)]
-
-extern crate cortex_m_srp;
-
-use cortex_m_srp::{C2, P2, Resource};
-
-static R1: Resource<i32, C2> = Resource::new(0);
-
-fn j1(mut prio: P2) {
- // OK only one `&mut-` reference to the data
- let r1 = R1.claim_mut(&mut prio);
-}
-
-fn j2(prio: P2) {
- // OK two `&-` references to the same data
- let r1 = R1.claim(&prio);
- let another_r1 = R1.claim(&prio);
-}
-
-fn j3(mut prio: P2) {
- // CAN'T have a `&-` reference and a `&mut-` reference to the same data
- let r1 = R1.claim(&prio);
- let another_r1 = R1.claim_mut(&mut prio);
- //~^ error
-}
-
-fn j4(mut prio: P2) {
- // CAN'T have two `&mut-` references to the same data
- let r1 = R1.claim_mut(&mut prio);
- let another_r1 = R1.claim_mut(&mut prio);
- //~^ error
-}
-
-fn main() {}