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:
Trevor Gross
2026-04-23 20:32:51 -04:00
committed by GitHub
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -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() }
}
+1 -1
View File
@@ -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.