Method | Description | |
---|---|---|
GetWaitQueueLength ( ICondition condition ) : int |
Returns an estimate of the number of threads waiting on the condition associated with this lock. Note that because timeouts and interrupts may occur at any time, the estimate serves only as an upper bound on the actual number of waiters. This method is designed for use in monitoring of the system state, not for synchronization control.
|
|
HasWaiters ( ICondition condition ) : bool |
Queries whether any threads are waiting on the condition associated with this lock. Note that because timeouts and interrupts may occur at any time, a
|
|
IsQueuedThread ( Thread thread ) : bool |
Queries whether the thread is waiting to acquire this lock. Note that because cancellations may occur at any time, a
|
|
Lock ( ) : IDisposable |
Acquires the lock and returns an IDisposable that can be used to unlock when disposed. Acquires the lock if it is not held by another thread and returns immediately, setting the lock hold count to one. If the If the lock is held by another thread then the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired, at which time the lock hold count is set to one. ReentrantLock reentrantLock = ...; using(reentrantLock.Lock()) { // locked } // unlocked. it is equvilant to ReentrantLock reentrantLock = ...; reentrantLock.Lock(); try { // locked } finally { reentrantLock.Unlock(); } // unlocked |
|
LockInterruptibly ( ) : IDisposable |
Acquires the lock unless System.Threading.Thread.Interrupt() is called on the current thread Acquires the lock if it is not held by another thread and returns immediately, setting the lock hold count to one. If the current thread already holds this lock then the hold count is incremented by one and the method returns immediately. If the lock is held by another thread then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of two things happens: If the lock is acquired by the current thread then the lock hold count is set to one. If the current thread: In this implementation, as this method is an explicit interruption point, preference is given to responding to the interrupt over normal or reentrant acquisition of the lock. Acquires the lock unless Thread.Interrupt() is called on the current thread. Returns an IDisposable that can be used to unlock if the lock is sucessfully obtained. Acquires the lock if it is not held by another thread and returns immediately, setting the lock hold count to one. If the current thread already holds this lock then the hold count is incremented by one and the method returns immediately. If the lock is held by another thread then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of two things happens:
If the lock is acquired by the current thread then the lock hold count is set to one. If the current thread:
then ThreadInterruptedException is thrown and the current thread's interrupted status is cleared. In this implementation, as this method is an explicit interruption point, preference is given to responding to the interrupt over normal or reentrant acquisition of the lock. ReentrantLock reentrantLock = ...; using(reentrantLock.LockInterruptibly()) { // locked } // unlocked. it is equvilant to ReentrantLock reentrantLock = ...; reentrantLock.LockInterruptibly(); try { // locked } finally { reentrantLock.Unlock(); } // unlocked |
|
NewCondition ( ) : ICondition |
Returns a Spring.Threading.Locks.ICondition instance for use with this Spring.Threading.Locks.ILock instance. The returned Spring.Threading.Locks.ICondition instance supports the same usages as do the System.Threading.Monitor methods System.Threading.Monitor.Wait(object), System.Threading.Monitor.Pulse(object), and System.Threading.Monitor.PulseAll(object)) when used with the built-in monitor lock.
|
|
ReentrantLock ( ) : System |
Creates an instance of Spring.Threading.Locks.ReentrantLock. This is equivalent to using ReentrantLock(false).
|
|
ReentrantLock ( bool fair ) : System |
Creates an instance of Spring.Threading.Locks.ReentrantLock with the given fairness policy.
|
|
ToString ( ) : string |
Returns a string identifying this lock, as well as its lock state. The state, in brackets, includes either the string 'Unlocked' or the string 'Locked by' followed by the System.Threading.Thread.Name of the owning thread.
|
|
TryLock ( ) : bool |
Acquires the lock only if it is not held by another thread at the time of invocation. Acquires the lock if it is not held by another thread and returns immediately with the value If the current thread already holds this lock then the hold count is incremented by one and the method returns If the lock is held by another thread then this method will return immediately with the value
|
|
TryLock ( System.TimeSpan timeSpan ) : bool |
Acquires the lock if it is not held by another thread within the given waiting time and System.Threading.Thread.Interrupt() hasn't been called on the current thread Acquires the lock if it is not held by another thread and returns immediately with the value If the current thread already holds this lock then the hold count is incremented by one and the method returns If the lock is held by another thread then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happens: If the lock is acquired then the value If the current thread: If the specified waiting time elapses then the value In this implementation, as this method is an explicit interruption point, preference is given to responding to the interrupt over normal or reentrant acquisition of the lock, and over reporting the elapse of the waiting time.
|
|
Unlock ( ) : void |
Attempts to release this lock. If the current thread is the holder of this lock then the hold count is decremented. If the hold count is now zero then the lock is released. If the current thread is not the holder of this lock then System.InvalidOperationException is thrown.
|
Method | Description | |
---|---|---|
GetWaitingThreads ( ICondition condition ) : ICollection |
Returns a collection containing those threads that may be waiting on the condition associated with this lock. Because the actual set of threads may change dynamically while constructing this result, the returned collection is only a best-effort estimate. The elements of the returned collection are in no particular order. This method is designed to facilitate construction of subclasses that provide more extensive condition monitoring facilities.
|
Method | Description | |
---|---|---|
AsConditionVariable ( ICondition condition ) : Java.Util.Concurrent.Locks.ConditionVariable | ||
IDisposable ( ) : void |
public GetWaitQueueLength ( ICondition condition ) : int | ||
condition | ICondition | the condition |
return | int |
protected GetWaitingThreads ( ICondition condition ) : ICollection |
||
condition | ICondition | the condition |
return | ICollection |
public HasWaiters ( ICondition condition ) : bool | ||
condition | ICondition | the condition |
return | bool |
public IsQueuedThread ( Thread thread ) : bool | ||
thread | Thread | the |
return | bool |
public ReentrantLock ( bool fair ) : System | ||
fair | bool | |
return | System |
public TryLock ( System.TimeSpan timeSpan ) : bool | ||
timeSpan | System.TimeSpan | the |
return | bool |