pub fn lock_device_creation() -> ReentrantMutexGuard<'static, ()>wgpu only.Expand description
Acquire the process-global wgpu device-creation lock. Hold the returned
guard across the whole Instance::new → request_adapter → request_device
sequence (and drop it once the device exists). Reentrant on the holding
thread, so a library call made inside the sequence that takes the lock
itself proceeds instead of deadlocking.
Prefer with_device_creation_lock for the common closure shape; this
guard form exists for call sites that interleave fallible ? steps and
cannot wrap the whole sequence in one closure.
Never hold the guard across an .await: it is !Send, and on a
single-threaded executor a second task taking the lock would block the
thread. wgpu’s native backend does its creation work when
request_adapter / request_device are called and returns an
already-resolved future, so locking the call alone is sufficient.