-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify time-service usage #12219
Simplify time-service usage #12219
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible that the polymorphism was used in Software Device?
@@ -305,8 +305,7 @@ namespace librealsense | |||
|
|||
rs2_time_t ds_timestamp_reader::get_frame_timestamp(const std::shared_ptr<frame_interface>& frame) | |||
{ | |||
std::lock_guard<std::recursive_mutex> lock(_mtx); | |||
return _ts->get_time(); | |||
return time_service::get_time(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the reason for the mutex originally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I don't know... but now that you mention it, I'll check if the mutex can be removed, too...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked: the mutex is now between the frame counter changes (frame_timestamp_reader::get_frame_counter()
when a frame is received and ::reset()
when a sensor is stopped). Before it included getting the current time (also on frame received). Maybe because frames can be received from parallel threads? Otherwise there'd be no reason for the mutex for counters, either...
I don't see how... there's no way to set the time-service per device. And I had to touch no code in the software device itself. I had 0 problems removing the polymorphism, and it was only exposed internally, inside librealsense. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A welcomed simplification.
LGTM
The class
time_service
was polymorphic before, and "created" by thebackend
.The idea was nice, but in reality usage was mixed between the backend and the
environment
. I tried centralizing it incontext
but ran into difficulties requiring refactoring in other places, and in the end decided that it just wasn't worth the effort and code complexity:environment
is really not good, as that's really used for the extrinsics information and we were abusing itThe code is now much simpler and easier to read/write. No weird backend usage in weird places, etc.
Tracked on [LRS-889]