Skip to content
Snippets Groups Projects
Commit e532588b authored by Philip Withnall's avatar Philip Withnall
Browse files

librhosydd: Add the current time to each RsdVehicle getter


Each vehicle has its own clock domain, which all timestamps for
attributes from that vehicle are relative to. This means that the
timestamps for two attributes from a given vehicle can be compared to
see which was updated more recently (and how much more recently, in
microseconds).

However, there was previously no way to compare timestamps between
vehicles, or to compare the timestamp for a given attribute to the
current time. Given that the clock domain for a vehicle could differ
arbitrarily from the system clock domain (g_get_monotonic_time()), this
meant that clients could never work out how long ago (in system clock
terms) an attribute was modified.

Fix that by exposing the current time in the vehicle’s clock domain with
the return value from each RsdVehicle getter which returns a property or
property metadata. This allows each attribute in those results to be
compared to the clock at the time of returning the results, to find out
how old that attribute value is, in microseconds.

This patch deliberately does not expose the current value of each
vehicle’s clock domain as a value by itself (for example, as a
get_current_time() method) as that would both tempt clients to poll it,
and would introduce unavoidable race conditions between getting the
current time and getting a set of attributes.

This breaks a lot of API.

The implementation in VddAggregateVehicle is worth paying attention to
when reviewing, as it needs to aggregate attributes from multiple
vehicles into a single aggregate vehicle. That means adjusting their
last-updated times to be in a single aggregate clock domain. This is
done by defining the aggregate clock domain to be g_get_monotonic_time()
and tracking the difference between that and each of the source
vehicles’ clocks with each value returned from those source vehicles.

Reviewed-by: default avatarSimon McVittie <simon.mcvittie@collabora.co.uk>
Signed-off-by: default avatarPhilip Withnall <philip.withnall@collabora.co.uk>
Differential Revision: https://phabricator.apertis.org/D3407
parent 1cdc1dda
No related tags found
Loading
Showing with 848 additions and 379 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment