C# 클래스 Microsoft.Common.Core.Threading.BinaryAsyncLock

BinaryAsyncLock is a helper primitive that can be used instead of SemaphoreSlim.WaitAsync + double-checked locking
After BinaryAsyncLock is created or reset, the first caller of WaitAsync will immediately get IBinaryAsyncLockToken that is not set. All other callers will either wait until IBinaryAsyncLockToken.Set is called and then will get , or until until IBinaryAsyncLockToken.Reset is called and next awaiting caller will get ,
파일 보기 프로젝트 열기: Microsoft/RTVS 1 사용 예제들

공개 메소드들

메소드 설명
BinaryAsyncLock ( bool isSet = false ) : System.Threading
EnqueueReset ( ) : void
ResetAsync ( CancellationToken cancellationToken = default(CancellationToken) ) : Task

Creates a task that is completed when lock is in Unset state and no reset waiters are in front of current one and all tokens that were issued prior this one are released

Method tries to replace current tail with the new Reset TokenSource (when its task is completed, lock will be in Unset state), and if it fails, it means that another thread has updated the tail, so method tries again with that new tail. If there is no tail, it is considered that lock is in the Unset state already, but no one has requested a token yet If there is a tail, method tries to set its TokenSource.Next to the new TokenSource, and if it fails, it means that another thread has updated the property or the tail, so method tries again with that new tail. If replacing tail succeeded, method stops adding Set tokens. If there are no unreleased set tokens, new tail task is set to completed.

WaitAsync ( CancellationToken cancellationToken = default(CancellationToken) ) : Task

비공개 메소드들

메소드 설명
TokenReset ( TokenSource tokenSource, bool setIfLast ) : void
TokenSet ( TokenSource tokenSource ) : void

메소드 상세

BinaryAsyncLock() 공개 메소드

public BinaryAsyncLock ( bool isSet = false ) : System.Threading
isSet bool
리턴 System.Threading

EnqueueReset() 공개 메소드

public EnqueueReset ( ) : void
리턴 void

ResetAsync() 공개 메소드

Creates a task that is completed when lock is in Unset state and no reset waiters are in front of current one and all tokens that were issued prior this one are released
Method tries to replace current tail with the new Reset TokenSource (when its task is completed, lock will be in Unset state), and if it fails, it means that another thread has updated the tail, so method tries again with that new tail. If there is no tail, it is considered that lock is in the Unset state already, but no one has requested a token yet If there is a tail, method tries to set its TokenSource.Next to the new TokenSource, and if it fails, it means that another thread has updated the property or the tail, so method tries again with that new tail. If replacing tail succeeded, method stops adding Set tokens. If there are no unreleased set tokens, new tail task is set to completed.
public ResetAsync ( CancellationToken cancellationToken = default(CancellationToken) ) : Task
cancellationToken System.Threading.CancellationToken
리턴 Task

WaitAsync() 공개 메소드

public WaitAsync ( CancellationToken cancellationToken = default(CancellationToken) ) : Task
cancellationToken System.Threading.CancellationToken
리턴 Task