mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-26 13:01:27 +03:00
Rollup merge of #155689 - zetanumbers:lock_latch_thread_local, r=ShoyuVanilla
Const initialize `LOCK_LATCH` thread local A simple refactor to avoid runtime thread-local initialization.
This commit is contained in:
@@ -220,7 +220,7 @@ pub(super) struct LockLatch {
|
||||
|
||||
impl LockLatch {
|
||||
#[inline]
|
||||
pub(super) fn new() -> LockLatch {
|
||||
pub(super) const fn new() -> LockLatch {
|
||||
LockLatch { m: Mutex::new(false), v: Condvar::new() }
|
||||
}
|
||||
|
||||
|
||||
@@ -524,7 +524,7 @@ unsafe fn in_worker_cold<OP, R>(&self, op: OP) -> R
|
||||
OP: FnOnce(&WorkerThread, bool) -> R + Send,
|
||||
R: Send,
|
||||
{
|
||||
thread_local!(static LOCK_LATCH: LockLatch = LockLatch::new());
|
||||
thread_local!(static LOCK_LATCH: LockLatch = const { LockLatch::new() });
|
||||
|
||||
LOCK_LATCH.with(|l| {
|
||||
// This thread isn't a member of *any* thread pool, so just block.
|
||||
|
||||
Reference in New Issue
Block a user