From 8e49af1cc0b8b3f4a3c9c4080e63d8d2ee1e6c36 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Tue, 29 May 2018 11:29:02 +0200 Subject: [PATCH] take Priority by shared reference in schedule_{after,now} --- macros/src/trans.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/macros/src/trans.rs b/macros/src/trans.rs index 7e14fdb7ff..d21a8a5b67 100644 --- a/macros/src/trans.rs +++ b/macros/src/trans.rs @@ -492,7 +492,7 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens { #[inline] pub fn schedule_now

( &mut self, - t: &mut ::#k::Priority

, + _p: &::#k::Priority

, #payload_in ) -> Result<(), #input_> where @@ -505,8 +505,9 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens { unsafe { use ::#k::Resource; + let p: &mut ::#k::Priority

= &mut ::#k::Priority::_new(); let slot = ::#name::FREE_QUEUE::new() - .claim_mut(t, |sq, _| sq.dequeue()); + .claim_mut(p, |sq, _| sq.dequeue()); if let Some(index) = slot { let task = ::#_priority::Task::#name; core::ptr::write( @@ -516,7 +517,7 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens { *#name::SCHEDULED_TIMES.get_unchecked_mut(index as usize) = self.scheduled_time(); - #_priority::READY_QUEUE::new().claim_mut(t, |q, _| { + #_priority::READY_QUEUE::new().claim_mut(p, |q, _| { q.split().0.enqueue_unchecked((task, index)); }); @@ -556,7 +557,7 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens { #[inline] pub fn schedule_now

( &mut self, - t: &mut ::#k::Priority

, + _p: &::#k::Priority

, #payload_in ) -> Result<(), #input_> where @@ -569,15 +570,16 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens { unsafe { use ::#k::Resource; + let p: &mut ::#k::Priority

= &mut ::#k::Priority::_new(); if let Some(index) = - ::#name::FREE_QUEUE::new().claim_mut(t, |sq, _| sq.dequeue()) { + ::#name::FREE_QUEUE::new().claim_mut(p, |sq, _| sq.dequeue()) { let task = ::#_priority::Task::#name; core::ptr::write( ::#name::PAYLOADS.get_unchecked_mut(index as usize), #payload_out, ); - ::#_priority::READY_QUEUE::new().claim_mut(t, |q, _| { + ::#_priority::READY_QUEUE::new().claim_mut(p, |q, _| { q.split().0.enqueue_unchecked((task, index)); }); @@ -647,7 +649,7 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens { #[inline] pub fn schedule_after

( &self, - t: &mut ::#k::Priority

, + p: &::#k::Priority

, after: u32, #payload_in ) -> Result<(), #input_> @@ -661,8 +663,9 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens { unsafe { use ::#k::Resource; + let p: &mut ::#k::Priority

= &mut ::#k::Priority::_new(); if let Some(index) = - ::#name::FREE_QUEUE::new().claim_mut(t, |sq, _| sq.dequeue()) { + ::#name::FREE_QUEUE::new().claim_mut(p, |sq, _| sq.dequeue()) { let ss = self.scheduled_time() + after; let task = ::_tq::Task::#name; @@ -679,7 +682,7 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens { task, }; - ::_tq::TIMER_QUEUE::new().claim_mut(t, |tq, _| tq.enqueue(m)); + ::_tq::TIMER_QUEUE::new().claim_mut(p, |tq, _| tq.enqueue(m)); Ok(()) } else {