Trait rtfm_core::Resource
[−]
[src]
pub unsafe trait Resource {
type Data: Send;
fn borrow<'cs>(&'cs self, t: &'cs Threshold) -> &'cs Self::Data;
fn borrow_mut<'cs>(&'cs mut self, t: &'cs Threshold) -> &'cs mut Self::Data;
fn claim<R, F>(&self, t: &mut Threshold, f: F) -> R
where
F: FnOnce(&Self::Data, &mut Threshold) -> R;
fn claim_mut<R, F>(&mut self, t: &mut Threshold, f: F) -> R
where
F: FnOnce(&mut Self::Data, &mut Threshold) -> R;
}A resource, a mechanism to share data between tasks
Associated Types
Required Methods
fn borrow<'cs>(&'cs self, t: &'cs Threshold) -> &'cs 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>(&'cs mut self, t: &'cs Threshold) -> &'cs mut Self::Data
Mutable variant of borrow
fn claim<R, F>(&self, t: &mut Threshold, f: F) -> R where
F: FnOnce(&Self::Data, &mut Threshold) -> R,
F: FnOnce(&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 Self::Data, &mut Threshold) -> R,
F: FnOnce(&mut Self::Data, &mut Threshold) -> R,
Mutable variant of claim