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.
Inheritance
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 |
---|---|---|
System.Threading.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 |
---|---|---|
System.Threading.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 |
---|---|---|
System.Threading.SemaphoreSlim | sem | the slim semaphore to acquire |
Returns
Type | Description |
---|---|
Synchronization.SemaphoreSlimLocker | the locker to use with langword_csharp_using |
LockAsync(SemaphoreSlim)
Creates a locker for a slim semaphore asynchronously.
Declaration
public static async Task<Synchronization.SemaphoreSlimAsyncLocker> LockAsync(SemaphoreSlim sem)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.SemaphoreSlim | sem | the slim semaphore to acquire async |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Synchronization.SemaphoreSlimAsyncLocker> | the locker to use with langword_csharp_using |
LockRead(ReaderWriterLockSlim)
Creates a locker for a read lock on a System.Threading.ReaderWriterLockSlim.
Declaration
public static Synchronization.ReaderWriterLockSlimReadLocker LockRead(ReaderWriterLockSlim rwl)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.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 System.Threading.ReaderWriterLockSlim.
Declaration
public static Synchronization.ReaderWriterLockSlimUpgradableReadLocker LockReadUpgradable(ReaderWriterLockSlim rwl)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.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 System.Threading.ReaderWriterLockSlim.
Declaration
public static Synchronization.ReaderWriterLockSlimWriteLocker LockWrite(ReaderWriterLockSlim rwl)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.ReaderWriterLockSlim | rwl | the lock to acquire in write mode |
Returns
Type | Description |
---|---|
Synchronization.ReaderWriterLockSlimWriteLocker | the locker to use with langword_csharp_using |