rtic icon indicating copy to clipboard operation
rtic copied to clipboard

Relax spawn_after parameter

Open ZoeyR opened this issue 3 years ago • 6 comments

With RTIC 1.0 if you use embedded_time on your Monotonic impl any call to task::spawn_after(...) has to put a .into() after the time type.

task::spawn_after(Milliseconds(250).into())

This is because the implementation of Monotonic requires using embedded_time::duration::Generic for the Duration associated type. This PR changes the bounds on the spawn_after function to take any type that can be converted into the target duration type. Removing the need to type all the into()s.

There are some backward-compatibility concerns since any code that previously used .into() will now fail the type inference. I'm also not sure how this affects the type inference for any Monotonic using fugit since I don't have a firmware repo to test with that.

ZoeyR avatar Jan 05 '22 13:01 ZoeyR

This seems fine to me. But it would be good to check if this had any negative effects such as increased size when the concrete type is not available anymore and must go through a trait. Both for embedded time and fugit.

korken89 avatar Jan 06 '22 07:01 korken89

Also, could you add a changelog line so it passes CI?

korken89 avatar Jan 06 '22 14:01 korken89

Sure thing! I've pushed the update.

ZoeyR avatar Jan 07 '22 10:01 ZoeyR

Was there any size increase when using embedded time or fugit in this way?

AfoHT avatar Jan 21 '22 12:01 AfoHT

Ping @ZoeyR

korken89 avatar Feb 10 '22 10:02 korken89

fugit will not work with Into

burrbull avatar Feb 10 '22 13:02 burrbull