Skip to content

Comments

Tee implementation without Clone requirement#744

Merged
frankmcsherry merged 10 commits intoTimelyDataflow:masterfrom
frankmcsherry:non_clone_tee
Feb 21, 2026
Merged

Tee implementation without Clone requirement#744
frankmcsherry merged 10 commits intoTimelyDataflow:masterfrom
frankmcsherry:non_clone_tee

Conversation

@frankmcsherry
Copy link
Member

@frankmcsherry frankmcsherry commented Feb 21, 2026

This is a bit of a proof of concept, stealing a bit from @antiguru's PR.

The goal is to support a Tee that does not have an inherent Clone requirement. Currently, the requirement exists because Tee itself is responsible for cloning containers when there are multiple consumers, and we need to have Tee to support any number of consumers.

The change here is to use a Box<dyn Push<T>> for the Tee, whose implementor either is or is not able to clone pushed containers, and handles that call without constraining Tee. The two implementors, PushOne and PushMany, respectively do not and do require Clone. The logic is set up so that the TeeHelper installs a PushMany only as the second pushee, and doing so could in principle live behind a method that has the C: Clone constraint.

It's not certain how to proceed, other than stealing further from @antiguru. Any concrete TeeHelper or StreamCore would need to either require Clone or not, and the ability to use it would depend on how we set that up. It seems "easy" to have two distinct types, but @antiguru reports that perhaps this is not necessary (the Streamlike trait not being required). Further investigation / copying is required!


Update: this proceeded to borrow more from @antiguru's work, with some ergonomic improvements (using Clone rather than tee and owned, which I give even odds we will end up regretting due to "too-clever-ness" footguns. We'll see).

@frankmcsherry frankmcsherry force-pushed the non_clone_tee branch 2 times, most recently from a37c02a to 3f66327 Compare February 21, 2026 21:42
Copy link
Member

@antiguru antiguru 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! Note to our future selves: we could likely change the input infrastructure to use the same pattern instead of requiring the data to be clone.

@frankmcsherry frankmcsherry marked this pull request as ready for review February 21, 2026 21:47
@frankmcsherry
Copy link
Member Author

Thanks very much for the help, and the inspiration!

@frankmcsherry frankmcsherry merged commit 14875e0 into TimelyDataflow:master Feb 21, 2026
7 checks passed
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.

2 participants