chore(external_printer)!: replace crossbeam with std::sync::mpsc - #1162
Open
kronberger-droid wants to merge 1 commit into
Open
chore(external_printer)!: replace crossbeam with std::sync::mpsc#1162kronberger-droid wants to merge 1 commit into
kronberger-droid wants to merge 1 commit into
Conversation
crossbeam pulled five sub-crates for one bounded channel that std has had since 1.0. The swap costs the Clone derive on ExternalPrinter, since std's Receiver is single-consumer by type; that clone only ever served the write side, which sender() covers. sender() now returns SyncSender, print() std's SendError. The feature name stays: six published crates enable it, and an empty feature is the compatibility escape hatch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
crossbeamwas in the tree for one bounded channel,and pulled five sub-crates along for it.
std::sync::mpsc::sync_channelcovers the same job,so this swaps the implementation and drops the dependency.
The
!is for two API edges:ExternalPrinterloses itsClonederive,since std's
Receiveris single-consumer by type,and
sender()now hands out astd::sync::mpsc::SyncSenderinstead of a crossbeamSender.Both are one-line changes for callers:
grab a
sender()per producer thread instead of cloning the printer,and
.send()has the same shape on either type.Before
crossbeam::channel::bounded, printer isClone(crossbeam channels are MPMC).After
std::sync::mpsc::sync_channel, one receiver owned by the engine, senders per producer.The example demonstrates the sender-per-thread pattern.