ScopedLockPair Class Reference 线程

#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

公共成员函数

  ScopedLockPair ( Spinlock &lock1, Spinlock &lock2)
  ScopedLockPair ( ScopedLockPair && src )
  ~ScopedLockPair ()

私有成员函数

  MAXON_DISALLOW_COPY_AND_ASSIGN ( ScopedLockPair )

Private Attributes

Spinlock _lock1
Spinlock _lock2

构造函数 & 析构函数文档编制

◆  ScopedLockPair() [1/2]

ScopedLockPair ( Spinlock lock1 ,
Spinlock lock2  
)

◆  ScopedLockPair() [2/2]

ScopedLockPair ( ScopedLockPair &&  src )

◆  ~ScopedLockPair()

~ ScopedLockPair ( )

成员函数文档编制

◆  MAXON_DISALLOW_COPY_AND_ASSIGN()

MAXON_DISALLOW_COPY_AND_ASSIGN ( ScopedLockPair   )
private

Member Data Documentation

◆  _lock1

Spinlock * _lock1
private

◆  _lock2

Spinlock * _lock2
private