-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Tracking issue for static synchronization primitives #27717
Copy link
Copy link
Closed
Labels
B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.In the final comment period and will be merged soon unless new substantive objections are raised.
Metadata
Metadata
Assignees
Labels
B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.In the final comment period and will be merged soon unless new substantive objections are raised.
Type
Fields
Give feedbackNo fields configured for issues without a type.
This is a tracking issue for the unstable
static_mutex,static_condvar, andstatic_rwlockfeatures in the standard library. Each of these represents a separateStaticFootype (next to the typeFoo) to provide a synchronization primitive that can be constructed in a static context. This unfortunately has a few drawbacks:StaticMutexdoes not have a type parameter for the data that it protects (unlikeMutex<T>)Ideally all of these types would be removed in favor of being able to construct a
Mutex<T>statically. This can almost be done withconst fn, but the implementation of each of these primitives currently has an internalBoxwhich can't be constructed in a static context. A solution should probably be devised along the lines of:Boxat runtime and just a plain address when inlined into a static. It also wouldn't have a destructor for the purposes of checking whether statics have destructors.boxoperator could be allowed in aconst fncontext perhaps. Instead of allocating memory on the heap it could instead "allocate" memory in the data section of an executable at compile time. The destructor would end up being ignored and never run somehow, possibly.