Trait cortex_m_rtfm::Resource
[−]
[src]
pub unsafe trait Resource { type Data: Send; fn borrow(&'cs self, t: &'cs Threshold) -> &'cs Static<Self::Data>; fn borrow_mut(
&'cs mut self,
t: &'cs Threshold
) -> &'cs mut Static<Self::Data>; fn claim<R, F>(&self, t: &mut Threshold, f: F) -> R
where
F: FnOnce(&Static<Self::Data>, &mut Threshold) -> R; fn claim_mut<R, F>(&mut self, t: &mut Threshold, f: F) -> R
where
F: FnOnce(&mut Static<Self::Data>, &mut Threshold) -> R; }
A resource, a mechanism to share data between tasks
Associated Types
Required Methods
fn borrow(&'cs self, t: &'cs Threshold) -> &'cs Static<Self::Data>
Borrows the resource data for the duration of a critical section
Panics
This will panic!
if the threshold is not high enough to protect the
resource data from data races
fn borrow_mut(&'cs mut self, t: &'cs Threshold) -> &'cs mut Static<Self::Data>
Mutable variant of borrow
fn claim<R, F>(&self, t: &mut Threshold, f: F) -> R where
F: FnOnce(&Static<Self::Data>, &mut Threshold) -> R,
F: FnOnce(&Static<Self::Data>, &mut Threshold) -> R,
Claims the resource data for the span of the closure f
. For the
duration of the closure other tasks that may access the resource data
are prevented from preempting the current task.
fn claim_mut<R, F>(&mut self, t: &mut Threshold, f: F) -> R where
F: FnOnce(&mut Static<Self::Data>, &mut Threshold) -> R,
F: FnOnce(&mut Static<Self::Data>, &mut Threshold) -> R,
Mutable variant of claim