views:

13

answers:

0

Hi!

I'm writing a component that reads data from a vehicle CAN-bus and offers a subscribe-interface to be used by the upper layer components. Part of the interface is that the subscriber can define a time of which a certain frame is considered to be timed out, and when that occurs the subscriber is notified.

Since the load of the bus can get quite heavy and there can be multiple subscribers of each frame (potentially with different timeouts) the performance of the timeout handling can be crucial.

The amount of frames in the system is counted in the hundreds and the transmission interval is everywhere from 30ms to 5s (the majority are sent every 100ms). The timeout is usually interval + 50%.

So far I've been using a solution with a separate thread that sweeps all subscribed frames and compares the latest timestamp with the current time. It works adequately, but I'm not satisfied with the code quality and it's up for a rewrite and therefore I'm thinking about other ways to address the problem.

Ideas anyone?