You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now (since #66 cleaned up a prior way more inconsistent state), sleep takes Ticks and sleep_extended takes a Duration.
Generally, either could take different kinds of times, eg. fugit types (as previously suggested in https://gitlab.com/etonomy/riot-wrappers/-/issues/6), possibly constructed from helper functions (sleep_seconds(5), sleep_milliseconds(500)). I think the expectation should be that anything accepted by sleep is convertible at build time, whereas sleep_extended may incur relatively costly transformations that may cause multiple sleeps on overflow.
The text was updated successfully, but these errors were encountered:
Given fugit allows a lot of constness, we could allow .sleep() to accept ticks or a compatible fugit type. Then, clock_ms.sleep(5.secs()) would should build time converted (but can't be enforced), clock_ms.sleep(Duration::secs(5)) would be too, and clock_ms.sleep(const { Duration::secs(5) }) would make the conversion a build time error (which is otherwise, AIU, a panic inside secs()).
chrysn
changed the title
ZTimer: Input types for _extended function
ZTimer: Input types for sleep{,_extended} functions
Aug 23, 2024
The const doesn't work quite that easily: The type can't be used for easy const construction because there there is also the parameter (u32/u64) which apparently can't be inferred even through a From/Into. Thus, the type needs annotations, and those can't be left incomplete without generic_arg_infer:
Right now (since #66 cleaned up a prior way more inconsistent state),
sleep
takes Ticks andsleep_extended
takes a Duration.Generally, either could take different kinds of times, eg.
fugit
types (as previously suggested in https://gitlab.com/etonomy/riot-wrappers/-/issues/6), possibly constructed from helper functions (sleep_seconds(5)
,sleep_milliseconds(500)
). I think the expectation should be that anything accepted bysleep
is convertible at build time, whereassleep_extended
may incur relatively costly transformations that may cause multiple sleeps on overflow.The text was updated successfully, but these errors were encountered: