Resource::new is also unsafe

This commit is contained in:
Jorge Aparicio 2017-03-08 08:22:31 -05:00
parent d88a15fb25
commit 388c34cc9f

View file

@ -48,7 +48,9 @@ impl<T> ResourceP<T> {
/// ///
/// # Unsafety /// # Unsafety
/// ///
/// - Do not create two resources that point to the same peripheral /// - Must not create two resources that point to the same peripheral
/// - The `ceiling` must be picked to prevent two or more concurrent tasks
/// from claiming this resource (preemptively)
pub const unsafe fn new(p: Peripheral<T>, ceiling: u8) -> Self { pub const unsafe fn new(p: Peripheral<T>, ceiling: u8) -> Self {
ResourceP { ResourceP {
peripheral: p, peripheral: p,
@ -84,7 +86,12 @@ impl<T> Resource<T> {
/// Initializes a resource /// Initializes a resource
/// ///
/// NOTE `ceiling` must be in the range `[1, 15]` /// NOTE `ceiling` must be in the range `[1, 15]`
pub const fn new(data: T, ceiling: u8) -> Self { ///
/// # Unsafety
///
/// - The `ceiling` must be picked to prevent two or more concurrent tasks
/// from claiming this resource (preemptively)
pub const unsafe fn new(data: T, ceiling: u8) -> Self {
Resource { Resource {
// NOTE elements 1 and 2 of the tuple are a poor man's const context // NOTE elements 1 and 2 of the tuple are a poor man's const context
// range checker // range checker