Bienvenue sur la nouvelle documentation de CppUtils !
CppUtils::Thread::MultipleAccessor<class... Lockers>
STRUCTRAII structure locking multiple lockers simultaneously without deadlocks.
Description
Section intitulée « Description »Uses std::scoped_lock internally to acquire all locks atomically in a deadlock-free manner, regardless of the order lockers are passed across different threads.
auto account0 = CppUtils::Thread::UniqueLocker<Account>{};auto account1 = CppUtils::Thread::UniqueLocker<Account>{};
{ auto lockBoth = CppUtils::Thread::MultipleAccessor{account0, account1}; auto& [firstAccount, secondAccount] = lockBoth.values; firstAccount.withdraw(100); secondAccount.deposit(100);}| Paramètre template | Description |
|---|---|
Lockers | Variadic list of locker types to lock simultaneously. |
Méthodes et fonctions publiques
Section intitulée « Méthodes et fonctions publiques »Locks all provided lockers atomically.
| Paramètre | Description |
|---|---|
lockers | Variadic references to lockers to lock. |
Attributs publics
Section intitulée « Attributs publics »std::tuple< decltype(std::declval< Lockers >().m_value)&... > values;