How to check if an xtimer is set?


with being merged the API of xtimer changed a bit. Before, one could check if an xtimer is set by deactivating the IRQ, checking if its members `target` and `long_target` were 0 and reactivating the IRQ (as was done in the xtimer-internal function `_is_set()` basically did as well).

Given that with the changes #9530 neither the members `target` and `long_target` nor the internal function `_is_set()` exist now, how does one check outside of the xtimer module, given an `xtimer_t` `a` that `a` is armed?

I used the previous method in to check if the inter-frame timer was set and only set it if that was not the case (otherwise my schedule gets messed up). As a workaround I use an external global boolean for now that is set whenever the timer is set and unset whenever the timer event is handled. I fear however, that this could lead to a race condition, so an intrinsic method to xtimer to determine if it is set would be preferred.

Best regards, Martine


the main change is that it is now offset based instead of absolute.

So instead of `target` and `long_target` you can check the new members `offset` and `long_offset` for being zero.

They are only set to zero once the timer was either fired or removed.

I also agree that an explicit `is_set()` would be a nice addition.