From 388c34cc9ff92f94e51d3ea0deb00aaa0564a6b3 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Wed, 8 Mar 2017 08:22:31 -0500 Subject: [PATCH] Resource::new is also unsafe --- src/lib.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e10b534dba..ae474f9c17 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,7 +48,9 @@ impl ResourceP { /// /// # 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, ceiling: u8) -> Self { ResourceP { peripheral: p, @@ -84,7 +86,12 @@ impl Resource { /// Initializes a resource /// /// 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 { // NOTE elements 1 and 2 of the tuple are a poor man's const context // range checker