Homepage GitHub

Libcanard calling canardRxAccept handler in O(1) time

On a system implementing many CanardRxSubscription instances you will end up with a big list to iterate trough when receiving a frame from canardRxAccept yielding a processing time of O(n).

Pavel made a proposal to change canardRxAccept() by adding a pointer to the associated CanardRxSession instance for OOP interfaces which might help. Although I’m not sure how to map a callback handler in O(1) to the returned CanardRxSubscription, would CanardRxSession also include a user pointer then aswell?

Another solution would make an optimized data structure for mapping PortID efficiently to pointers/callbacks. But that feels more like re-inventing the wheel.

This is correct, although keep in mind that if the subscription configuration is constant, then so is the processing time (O(n), n = const). This complexity does not depend on the network configuration, therefore the temporal properties of the local application are robustly predictable.

Yes. Actually, I already have this implemented in a private fork. Should I send a pull request against the upstream? Would you be available to write a basic unit test for this?

Hi Pavel,

If you could make your fork public, I could test it next week and if it solves the problem I’ve got.
I can write a unit test for it.