Skip to content

ref(core): Reduce unsafe access in hub switching - #1123

Merged
szokeasaurusrex merged 1 commit into
masterfrom
szokeasaurusrex/hub-refcell
May 11, 2026
Merged

szokeasaurusrex merged 1 commit into
masterfrom
szokeasaurusrex/hub-refcell

Conversation

@szokeasaurusrex

Copy link
Copy Markdown
Member

Use RefCell for the thread-local hub slot.

@szokeasaurusrex
szokeasaurusrex requested a review from giortzisg May 7, 2026 12:59
@szokeasaurusrex
szokeasaurusrex marked this pull request as ready for review May 7, 2026 12:59
@szokeasaurusrex
szokeasaurusrex requested a review from lcian as a code owner May 7, 2026 12:59
Use RefCell for the thread-local hub slot.

@lcian lcian left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@szokeasaurusrex
szokeasaurusrex merged commit bd97942 into master May 11, 2026
23 checks passed
@szokeasaurusrex
szokeasaurusrex deleted the szokeasaurusrex/hub-refcell branch May 11, 2026 11:01
szokeasaurusrex added a commit that referenced this pull request May 26, 2026
Following the safety improvements in #1123, `Hub::with` no longer offers any performance benefit over using `Hub::current`. `Hub::current` provides a simpler API, and also returns an owned `Arc<Hub>` rather than providing access to a `&Arc<Hub>` via a callback (necessitating a second clone for anyone needing an owned `Arc<Hub>` in that callback).

As `Hub::current` is the arguably better API, let's deprecate `Hub::with` and encourage folks to migrate.
szokeasaurusrex added a commit that referenced this pull request May 26, 2026
Following the safety improvements in #1123, `Hub::with` no longer offers any performance benefit over using `Hub::current`. `Hub::current` provides a simpler API, and also returns an owned `Arc<Hub>` rather than providing access to a `&Arc<Hub>` via a callback (necessitating a second clone for anyone needing an owned `Arc<Hub>` in that callback).

As `Hub::current` is the arguably better API, let's deprecate `Hub::with` and encourage folks to migrate.
szokeasaurusrex added a commit that referenced this pull request May 26, 2026
Following the safety improvements in #1123, `Hub::with` no longer offers
any performance benefit over using `Hub::current`. `Hub::current`
provides a simpler API, and also returns an owned `Arc<Hub>` rather than
providing access to a `&Arc<Hub>` via a callback (necessitating a second
clone for anyone needing an owned `Arc<Hub>` in that callback).

As `Hub::current` is the arguably better API, let's deprecate
`Hub::with` and encourage folks to migrate.

Stacked on #1125
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.

3 participants