From c3a35c1b6cea81aa71e8832bca79ccafa492be02 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Tue, 7 Mar 2017 22:56:06 -0500 Subject: revamp for memory safety --- src/interrupt.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/interrupt.rs') diff --git a/src/interrupt.rs b/src/interrupt.rs index 2552892..95829ca 100644 --- a/src/interrupt.rs +++ b/src/interrupt.rs @@ -72,21 +72,22 @@ pub fn enable() { /// Critical section token /// /// Indicates that you are executing code within a critical section -pub struct CsToken { - _private: (), +pub struct CsCtxt { + _0: (), } /// Execute closure `f` in an interrupt-free context. +/// /// This as also known as a "critical section". pub fn free(f: F) -> R - where F: FnOnce(&CsToken) -> R + where F: FnOnce(&CsCtxt) -> R { let primask = ::register::primask::read(); // disable interrupts disable(); - let r = f(&CsToken { _private: () }); + let r = f(&CsCtxt { _0: () }); // If the interrupts were active before our `disable` call, then re-enable // them. Otherwise, keep them disabled -- cgit v1.2.3