mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-23 20:22:51 +01:00
take Priority by shared reference in schedule_{after,now}
This commit is contained in:
parent
9f6247b438
commit
8e49af1cc0
1 changed files with 12 additions and 9 deletions
|
@ -492,7 +492,7 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn schedule_now<P>(
|
pub fn schedule_now<P>(
|
||||||
&mut self,
|
&mut self,
|
||||||
t: &mut ::#k::Priority<P>,
|
_p: &::#k::Priority<P>,
|
||||||
#payload_in
|
#payload_in
|
||||||
) -> Result<(), #input_>
|
) -> Result<(), #input_>
|
||||||
where
|
where
|
||||||
|
@ -505,8 +505,9 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
unsafe {
|
unsafe {
|
||||||
use ::#k::Resource;
|
use ::#k::Resource;
|
||||||
|
|
||||||
|
let p: &mut ::#k::Priority<P> = &mut ::#k::Priority::_new();
|
||||||
let slot = ::#name::FREE_QUEUE::new()
|
let slot = ::#name::FREE_QUEUE::new()
|
||||||
.claim_mut(t, |sq, _| sq.dequeue());
|
.claim_mut(p, |sq, _| sq.dequeue());
|
||||||
if let Some(index) = slot {
|
if let Some(index) = slot {
|
||||||
let task = ::#_priority::Task::#name;
|
let task = ::#_priority::Task::#name;
|
||||||
core::ptr::write(
|
core::ptr::write(
|
||||||
|
@ -516,7 +517,7 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
*#name::SCHEDULED_TIMES.get_unchecked_mut(index as usize) =
|
*#name::SCHEDULED_TIMES.get_unchecked_mut(index as usize) =
|
||||||
self.scheduled_time();
|
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));
|
q.split().0.enqueue_unchecked((task, index));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -556,7 +557,7 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn schedule_now<P>(
|
pub fn schedule_now<P>(
|
||||||
&mut self,
|
&mut self,
|
||||||
t: &mut ::#k::Priority<P>,
|
_p: &::#k::Priority<P>,
|
||||||
#payload_in
|
#payload_in
|
||||||
) -> Result<(), #input_>
|
) -> Result<(), #input_>
|
||||||
where
|
where
|
||||||
|
@ -569,15 +570,16 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
unsafe {
|
unsafe {
|
||||||
use ::#k::Resource;
|
use ::#k::Resource;
|
||||||
|
|
||||||
|
let p: &mut ::#k::Priority<P> = &mut ::#k::Priority::_new();
|
||||||
if let Some(index) =
|
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;
|
let task = ::#_priority::Task::#name;
|
||||||
core::ptr::write(
|
core::ptr::write(
|
||||||
::#name::PAYLOADS.get_unchecked_mut(index as usize),
|
::#name::PAYLOADS.get_unchecked_mut(index as usize),
|
||||||
#payload_out,
|
#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));
|
q.split().0.enqueue_unchecked((task, index));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -647,7 +649,7 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn schedule_after<P>(
|
pub fn schedule_after<P>(
|
||||||
&self,
|
&self,
|
||||||
t: &mut ::#k::Priority<P>,
|
p: &::#k::Priority<P>,
|
||||||
after: u32,
|
after: u32,
|
||||||
#payload_in
|
#payload_in
|
||||||
) -> Result<(), #input_>
|
) -> Result<(), #input_>
|
||||||
|
@ -661,8 +663,9 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
unsafe {
|
unsafe {
|
||||||
use ::#k::Resource;
|
use ::#k::Resource;
|
||||||
|
|
||||||
|
let p: &mut ::#k::Priority<P> = &mut ::#k::Priority::_new();
|
||||||
if let Some(index) =
|
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 ss = self.scheduled_time() + after;
|
||||||
let task = ::_tq::Task::#name;
|
let task = ::_tq::Task::#name;
|
||||||
|
|
||||||
|
@ -679,7 +682,7 @@ pub fn app(ctxt: &Context, app: &App) -> Tokens {
|
||||||
task,
|
task,
|
||||||
};
|
};
|
||||||
|
|
||||||
::_tq::TIMER_QUEUE::new().claim_mut(t, |tq, _| tq.enqueue(m));
|
::_tq::TIMER_QUEUE::new().claim_mut(p, |tq, _| tq.enqueue(m));
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue