Repository navigation
vehicle_time: Deliver VehicleClock callbacks from a worker thread - #215
florianfueller wants to merge 4 commits into
Conversation
License Check Results🚀 The license check job ran with the Bazel command: bazel run //:license-checkStatus: Click to expand output |
d4f4e67 to
143d1fb
Compare
143d1fb to
d447876
Compare
d447876 to
a816147
Compare
c811e27 to
041c9b8
Compare
041c9b8 to
4448f49
Compare
4448f49 to
756eaad
Compare
756eaad to
28b62ff
Compare
e5731ec to
150c89a
Compare
| const auto status_flags = ConvertPtpStatus(snapshot.value().status); | ||
| score::cpp::ignore = | ||
| status_slot_.InvokeIfChanged(status_flags, VehicleTimeStatus{status_flags, snapshot.value().rate_deviation}); | ||
| score::cpp::ignore = sync_data_slot_.TryDeliverChangedData(ConvertSyncData(snapshot.value().sync_fup_data)); |
There was a problem hiding this comment.
why do we need still to ignore the result?
regarding the returning result.
I think, the point, the callback was executed or nto is indeed not interesting.
but if the callback will return some result and we can react on it - that might be interesting.
but do we need this thing?
one of the use case - the callback could return if the registration shall still be hold.
so, if it will return true - continue calling it, false - drop the subscription.
if not, I would propose to drop the return at all.
|
|
||
| void SvtCallbackDispatcher::PollAndDispatch() noexcept | ||
| { | ||
| const auto snapshot = svt_receiver_->Receive(); |
There was a problem hiding this comment.
then we need to investigate before we will merge it
| template <typename Timebase> | ||
| bool IsSameForDelivery(const TimeSlaveSyncData<Timebase>& first, const TimeSlaveSyncData<Timebase>& second) noexcept | ||
| { | ||
| const bool same_precise_origin_timestamp = (first.precise_origin_timestamp == second.precise_origin_timestamp); |
There was a problem hiding this comment.
why the default instantiation doesn't fit here?
| bool IsSameForDelivery(const PDelayMeasurementData<Timebase>& first, | ||
| const PDelayMeasurementData<Timebase>& second) noexcept | ||
| { | ||
| const bool same_request_origin_timestamp = (first.request_origin_timestamp == second.request_origin_timestamp); |
There was a problem hiding this comment.
why the default instantiation doesn't fit here?
| /// @brief Thread-safe holder for a single move-only callback that is invoked from a dedicated worker thread | ||
| /// @brief Delivery comparison for types that already provide @c operator==. | ||
| template <typename Value> | ||
| bool IsSameForDelivery(const Value& first, const Value& second) noexcept |
There was a problem hiding this comment.
Not sure, I can understand the function name
| /// @return @c true if the callback was invoked, @c false if none is installed or @p data is unchanged. | ||
| template <typename Argument> | ||
| bool InvokeIfChanged(const Data& data, const Argument& argument) noexcept | ||
| bool TryDeliverChangedData(const Data& data) noexcept |
There was a problem hiding this comment.
is it a delivery?
Maybe TryToEnvoke() or somehting?
also the user of this function doesn't know, what the "new" data is.
he jsut has the "data"
| std::recursive_mutex mutex_; | ||
| std::shared_ptr<Callback> callback_{}; | ||
| std::optional<Data> last_data_{}; | ||
| // Mirrors callback_ != nullptr. Written only under mutex_, read lock-free by IsSet(). |
There was a problem hiding this comment.
I don't think, we need this comment
22c6f71 to
0eee42c
Compare
|
Documentation preview for this pull request is available at: |
The Set/Unset callback methods of VehicleClockBackendImpl were no-ops.
Callbacks are now delivered by a worker thread that polls the
TimeDaemon shared memory every 50 ms:
and runs until the backend is destroyed. While no callback is
registered it sleeps.
and afterwards only changes of its part of the snapshot:
TimeSlaveSyncData and PDelayMeasurementData on any change,
VehicleTimeStatus only when the flags change (rate deviation
excluded).
callback; Unset returns only after a running invocation finished.
Add unit tests, update the docs and remove the "not yet delivered"
warnings.
closes #59 (improvement ticket)