require Resource protected data to be Send, make tokens !Send

This commit is contained in:
Jorge Aparicio 2017-05-08 13:25:20 -05:00
parent fc4cb7d472
commit c1a0f8173a
2 changed files with 171 additions and 1 deletions

View file

@ -419,6 +419,7 @@
#![deny(warnings)]
#![feature(asm)]
#![feature(const_fn)]
#![feature(optin_builtin_traits)]
#![no_std]
extern crate cortex_m;
@ -533,7 +534,11 @@ impl<T, RC> Resource<T, Ceiling<RC>> {
}
}
unsafe impl<T, C> Sync for Resource<T, C> {}
unsafe impl<T, C> Sync for Resource<T, C>
where
T: Send,
{
}
/// A hardware peripheral as a resource
///
@ -684,6 +689,8 @@ pub struct Ceiling<N> {
_marker: PhantomData<N>,
}
impl<N> !Send for Ceiling<N> {}
/// Preemption threshold
pub struct Threshold<T> {
_marker: PhantomData<T>,
@ -710,6 +717,8 @@ impl<PT> Threshold<PT> {
}
}
impl<N> !Send for Threshold<N> {}
/// Priority
pub struct Priority<N> {
_marker: PhantomData<N>,
@ -725,6 +734,8 @@ where
}
}
impl<N> !Send for Priority<N> {}
/// Maps a `Resource` / `Peripheral` to its ceiling
///
/// Do not implement this trait yourself. This is an implementation detail.