Skip to content

Unify id-based thread parking implementations - #105903

Merged
bors merged 4 commits into
rust-lang:masterfrom
joboet:unify_parking
Dec 31, 2022
Merged

bors merged 4 commits into
rust-lang:masterfrom
joboet:unify_parking

Conversation

@joboet

@joboet joboet commented Dec 19, 2022 •

Copy link
Copy Markdown
Member

View all comments

Multiple platforms currently use thread-id-based parking implementations (NetBSD and SGX1). Even though the strategy does not differ, these are duplicated for each platform, as the id is encoded into an atomic thread variable in different ways for each platform.

Since park is only called by one thread, it is possible to move the thread id into a separate field. By ensuring that the field is only written to once, before any other threads access it, these accesses can be unsynchronized, removing any restrictions on the size and niches of the thread id.

This PR also renames the internal thread_parker modules to thread_parking, as that name now better reflects their contents. I hope this does not add too much reviewing noise.

r? @m-ou-se

@rustbot label +T-libs

Footnotes

  1. SOLID supports this as well, I will switch it over in a follow-up PR. ↩

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-networking Area: `std::net` A-thread Area: `std::thread` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants