Skip to content

Conversation

@emilk
Copy link
Member

@emilk emilk commented Dec 2, 2025

re_smart_channel is a monster that has evolved over time.

This takes a big step towards simplifying it

  • Renamed re_smart_channel to re_log_channel
  • Removes the generics - it always wraps a DataSourceMessage now
  • Renamed Sender<T>/Receiver<T> to LogSender/LogReceiver
  • Removed the latency metrics - we are no longer using it
  • Use a much simpler design for the "ui waker" mechanism
  • Combine SmartMessageSource and SmartChannelSource into a single LogSource
@emilk emilk added 🚜 refactor Change the code, not the functionality exclude from changelog PRs with this won't show up in CHANGELOG.md labels Dec 2, 2025
@github-actions
Copy link

github-actions bot commented Dec 2, 2025

Web viewer failed to build.

Result Commit Link Manifest
https://rerun.io/viewer/pr/12052 +nightly +main

View image diff on kitdiff.

Note: This comment is updated whenever you push a commit.

@emilk emilk force-pushed the emilk/log-channel branch from 1abaaaf to 196c4ef Compare December 2, 2025 17:04
@emilk emilk force-pushed the emilk/log-channel branch from 196c4ef to b4917a1 Compare December 2, 2025 17:06
@lucasmerlin lucasmerlin self-requested a review December 3, 2025 09:30
use crate::{Channel, LogSource, SendError, SmartMessage, SmartMessagePayload};

#[derive(Clone)]
pub struct LogSender {
Copy link
Member Author

Choose a reason for hiding this comment

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

For some reason git didn't realize this is mostly a rename of the old sender file, but with generics removed


use crate::{Channel, LogSource, SmartMessage, TryRecvError};

pub struct LogReceiver {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is mostly a rename of the old receiver file, but with generics removed

Comment on lines +29 to +34
/// Call this on each sent message.
///
/// Can be used to wake up the receiver thread.
pub fn set_waker(&self, waker: impl Fn() + Send + Sync + 'static) {
*self.channel.waker.write() = Some(Box::new(waker));
}
Copy link
Member Author

Choose a reason for hiding this comment

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

this is new though

Copy link
Member

@lucasmerlin lucasmerlin left a comment

Choose a reason for hiding this comment

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

Looks good!

Comment on lines 78 to 101
/// Used to indicate that a sender has left.
///
/// This sends a message down the channel allowing the receiving end to know whether one of the
/// sender has left, and if so why (if applicable).
///
/// Using a [`LogSender`] after calling `quit` is undefined behavior: the receiving end is free
/// to silently drop those messages (or worse).
pub fn quit(
&self,
err: Option<Box<dyn std::error::Error + Send>>,
) -> Result<(), SendError<Box<SmartMessage>>> {
self.tx
.send(SmartMessage {
source: Arc::clone(&self.source),
payload: SmartMessagePayload::Quit(err),
})
.map_err(|SendError(msg)| SendError(Box::new(msg)))?;

if let Some(waker) = self.channel.waker.read().as_ref() {
(waker)();
}

Ok(())
}
Copy link
Member

Choose a reason for hiding this comment

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

Should dropping the Sender also call Quit?

Copy link
Member Author

@emilk emilk Dec 3, 2025

Choose a reason for hiding this comment

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

No - the Quit shows intention. I'll add a comment to that effect.
Also the LogSender is clonable, so we really don't wanna quit on drop.

/// ⚠️ This function must be called from the main thread since some platforms require that
/// their UI runs on the main thread! ⚠️
pub fn show(main_thread_token: crate::MainThreadToken, msgs: Vec<LogMsg>) -> eframe::Result {
let log_source = re_log_channel::LogSource::Sdk; // Whatever. Nobody is really using this functions anyhow.
Copy link
Member

Choose a reason for hiding this comment

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

Then why not get rid of this? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

It's part of our public API. We can mark it #[deprecated] but that feels out-of-bounds for this PR

@emilk emilk merged commit 3a1c8cb into main Dec 3, 2025
21 of 22 checks passed
@emilk emilk deleted the emilk/log-channel branch December 3, 2025 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

exclude from changelog PRs with this won't show up in CHANGELOG.md 🚜 refactor Change the code, not the functionality

4 participants