Skip to content
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

Make the Ephemeris fully thread-safe and improve error reporting #2088

Merged
merged 6 commits into from
Mar 10, 2019

Conversation

pleroy
Copy link
Member

@pleroy pleroy commented Mar 8, 2019

Also take advantage of the fact that ContinuousTrajectory is now thread-safe.

@@ -396,10 +408,10 @@ void Ephemeris<Frame>::Prolong(Instant const& t) {
// actually reaches |t| because the last series may not be fully determined
// after the first integration.
absl::MutexLock l(&lock_);
while (t_max_locked() < t) {
do {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should still be while (t_max() < t) : t_max() < t may have become true between the short-circuit and the acquisition of the lock (because of a simultaneous call to Prolong).

Consider adding a test that would have caught this.


// The maximum of the |t_min|s of the trajectories.
virtual Instant t_min() const EXCLUDES(lock_);
// The mimimum of the |t_max|s of the trajectories.
virtual Instant t_max() const EXCLUDES(lock_);
virtual Instant t_max() const;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment: the values of t_min() and t_max() are only affected by calls to Prolong and ForgetBefore; while lock_ is held, their value cannot be changed by another thread.

In the absence of calls to ForgetBefore, t_max() can only increase, and t_min() can only decrease.

This effectively makes ForgetBefore hostile to operating on a trajectory from another thread.

Perhaps we should get rid of it; it makes things very messy.

@eggrobin eggrobin added the LGTM label Mar 10, 2019
@pleroy pleroy merged commit f4413fb into mockingbirdnest:master Mar 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants