Skip to content

chore(external_printer)!: replace crossbeam with std::sync::mpsc - #1162

Open
kronberger-droid wants to merge 1 commit into
nushell:mainfrom
kronberger-droid:chore/drop-crossbeam
Open

chore(external_printer)!: replace crossbeam with std::sync::mpsc#1162
kronberger-droid wants to merge 1 commit into
nushell:mainfrom
kronberger-droid:chore/drop-crossbeam

Conversation

@kronberger-droid

Copy link
Copy Markdown
Collaborator

Summary

crossbeam was in the tree for one bounded channel,
and pulled five sub-crates along for it.
std::sync::mpsc::sync_channel covers the same job,
so this swaps the implementation and drops the dependency.

The ! is for two API edges:
ExternalPrinter loses its Clone derive,
since std's Receiver is single-consumer by type,
and sender() now hands out a std::sync::mpsc::SyncSender instead of a crossbeam Sender.
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 is Clone (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.

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.
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.

1 participant