Class Synchronization
Utilities for inter-thread synchronization. All Locker method acquire their object immediately, and should only be used with langword_csharp_using to automatically release them.
Inherited Members
Namespace: IPA.Utilities.Async
Assembly: IPA.Loader.dll
Syntax
public static class Synchronization
Examples
The canonical usage of all of the member functions is as follows, substituting Lock(Mutex) with whichever member you want to use, according to your lock type.
using var _locker = Synchronization.Lock(mutex);
Methods
| Improve this Doc View SourceLock(Mutex)
Creates a locker for a mutex.
Declaration
public static Synchronization.MutexLocker Lock(Mutex mut)
Parameters
Type | Name | Description |
---|---|---|
Mutex | mut | the mutex to acquire |
Returns
Type | Description |
---|---|
Synchronization.MutexLocker | the locker to use with langword_csharp_using |
Lock(Semaphore)
Creates a locker for a semaphore.
Declaration
public static Synchronization.SemaphoreLocker Lock(Semaphore sem)
Parameters
Type | Name | Description |
---|---|---|
Semaphore | sem | the semaphore to acquire |
Returns
Type | Description |
---|---|
Synchronization.SemaphoreLocker | the locker to use with langword_csharp_using |
Lock(SemaphoreSlim)
Creates a locker for a slim semaphore.
Declaration
public static Synchronization.SemaphoreSlimLocker Lock(SemaphoreSlim sem)
Parameters
Type | Name | Description |
---|---|---|
SemaphoreSlim | sem | the slim semaphore to acquire |
Returns
Type | Description |
---|---|
Synchronization.SemaphoreSlimLocker | the locker to use with langword_csharp_using |
LockRead(ReaderWriterLockSlim)
Creates a locker for a read lock on a ReaderWriterLockSlim.
Declaration
public static Synchronization.ReaderWriterLockSlimReadLocker LockRead(ReaderWriterLockSlim rwl)
Parameters
Type | Name | Description |
---|---|---|
ReaderWriterLockSlim | rwl | the lock to acquire in read mode |
Returns
Type | Description |
---|---|
Synchronization.ReaderWriterLockSlimReadLocker | the locker to use with langword_csharp_using |
LockReadUpgradable(ReaderWriterLockSlim)
Creates a locker for an upgradable read lock on a ReaderWriterLockSlim.
Declaration
public static Synchronization.ReaderWriterLockSlimUpgradableReadLocker LockReadUpgradable(ReaderWriterLockSlim rwl)
Parameters
Type | Name | Description |
---|---|---|
ReaderWriterLockSlim | rwl | the lock to acquire in upgradable read mode |
Returns
Type | Description |
---|---|
Synchronization.ReaderWriterLockSlimUpgradableReadLocker | the locker to use with langword_csharp_using |
LockWrite(ReaderWriterLockSlim)
Creates a locker for a write lock ReaderWriterLockSlim.
Declaration
public static Synchronization.ReaderWriterLockSlimWriteLocker LockWrite(ReaderWriterLockSlim rwl)
Parameters
Type | Name | Description |
---|---|---|
ReaderWriterLockSlim | rwl | the lock to acquire in write mode |
Returns
Type | Description |
---|---|
Synchronization.ReaderWriterLockSlimWriteLocker | the locker to use with langword_csharp_using |