#include <spinlock.h>
详细描述
A
ScopedLockPair
acquires locks to two specified mutexes upon creation and releases them upon destruction (usually at the end of a code block). You should use this instead of two
ScopedLock
objects to avoid deadlocks: With two separate
ScopedLock
objects one thread could lock A and then try to lock B, while another thread could lock B and then try to lock A, resulting in a deadlock.
ScopedLockPair
avoids this by always locking the mutex with lower memory address at first.
-
另请参阅
-
SpinLock
-
ScopedLock