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

The data protected by the resource

Required Methods

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

Mutable variant of borrow

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.

Mutable variant of claim

Implementors