Skip to content

Conversation

@notoriaga
Copy link
Contributor

No description provided.

/// - `utc_time`: The stored monotonic Utc time.
/// - `week`: The stored week value from GPS Time messages.
pub struct BaselineTab<'a, S: CapnProtoSender> {
pub struct BaselineTab<S: CapnProtoSender> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the existing lifetimes on tabs, because the references they were using were 'static so they were unneeded

func: Box<dyn FnMut(SBP, MaybeGpsTime) + Send + 'a>,
msg_types: &'static [u16],
enum Callback<'a> {
Id {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed id based callbacks for settings stuff, it was easier to just include it there than breaking it out

pub solution_velocity: Mutex<SolutionVelocityTab<S>>,
pub advanced_spectrum_analyzer: Mutex<AdvancedSpectrumAnalyzerTab<S>>,
pub status_bar: Mutex<StatusBar<S>>,
_link: broadcaster::Link<'link>,
Copy link
Contributor Author

@notoriaga notoriaga Sep 2, 2021

Choose a reason for hiding this comment

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

Added this just to show that everything compiles when Tabs is holding a Link (so should work for Fileio as well)

Comment on lines +242 to +248
pub fn link<'scope>(&self) -> Link<'scope>
where
'env: 'scope,
{
let link: Link<'scope> = unsafe { std::mem::transmute(self.link.clone()) };
link
}
Copy link
Contributor Author

@notoriaga notoriaga Sep 2, 2021

Choose a reason for hiding this comment

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

This lets you create Links from LinkSource with distinct lifetimes ('scope), that are at most as long as 'env (the 'parent' lifetime). This basically forces the behavior that @silverjam was talking about w.r.t. how clone should intuitively behave in this case.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This makes sense to me!

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@notoriaga notoriaga requested review from john-michaelburke and silverjam and removed request for john-michaelburke September 2, 2021 19:09
use std::{convert::TryInto, marker::PhantomData, sync::Arc, time::Duration};

use crossbeam::channel;
use parking_lot::Mutex;
Copy link
Collaborator

@john-michaelburke john-michaelburke Sep 2, 2021

Choose a reason for hiding this comment

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

What do we gain with the parkinglot mutex? Looks like it doesnt require unwrapping the lock.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what specifically we needed for this change though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah another thing I needed for the settings tab. It has a function to unlock a mutex without a guard (https://docs.rs/lock_api/0.4.5/lock_api/struct.Mutex.html#method.force_unlock) which I needed for the FFI stuff. Don't actually need it here I guess.

They are supposed to be faster, and they don't allocate their contents on the heap like std mutexs. You don't have to unwrap them because they don't 'poison'. So if a thread holding a mutex panics it just releases the mutex. Which is supposed to be fine for 'normal' panics like unwrap() and stuff. The poisoning is an extra safeguard against panics that leave the contents of the mutex in an 'undefined' state which is apparently very uncommon

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds like it should be safe for us then too

@notoriaga notoriaga merged commit 71aa280 into main Sep 2, 2021
@notoriaga notoriaga deleted the steve/link2 branch September 2, 2021 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants