public bool EnterAsync(TimeSpan timeout, FastAsyncCallback callback, object state) { bool flag; lock (this.ThisLock) { if (!this.aborted) { if (this.count >= this.maxCount) { AsyncWaitHandle asyncWaitHandle = new AsyncWaitHandle(); this.Waiters.Enqueue(asyncWaitHandle); return(asyncWaitHandle.WaitAsync(ThreadNeutralSemaphore.EnteredAsyncCallback, new ThreadNeutralSemaphore.EnterAsyncData(this, asyncWaitHandle, callback, state), timeout)); } else { ThreadNeutralSemaphore threadNeutralSemaphore = this; threadNeutralSemaphore.count = threadNeutralSemaphore.count + 1; flag = true; } } else { throw Fx.Exception.AsError(this.CreateObjectAbortedException()); } } return(flag); }
public bool EnterAsync(TimeSpan timeout, FastAsyncCallback callback, object state) { Fx.Assert(callback != null, "must have a non-null call back for async purposes"); AsyncWaitHandle waiter = null; lock (this.ThisLock) { if (this.aborted) { throw Fx.Exception.AsError(CreateObjectAbortedException()); } if (this.count < this.maxCount) { this.count++; return(true); } waiter = new AsyncWaitHandle(); this.Waiters.Enqueue(waiter); } return(waiter.WaitAsync(EnteredAsyncCallback, new EnterAsyncData(this, waiter, callback, state), timeout)); }
public bool EnterAsync(TimeSpan timeout, FastAsyncCallback callback, object state) { Fx.Assert(callback != null, "must have a non-null call back for async purposes"); AsyncWaitHandle waiter = null; lock (this.ThisLock) { if (this.aborted) { throw Fx.Exception.AsError(CreateObjectAbortedException()); } if (this.count < this.maxCount) { this.count++; return true; } waiter = new AsyncWaitHandle(); this.Waiters.Enqueue(waiter); } return waiter.WaitAsync(EnteredAsyncCallback, new EnterAsyncData(this, waiter, callback, state), timeout); }
public bool EnterAsync(TimeSpan timeout, FastAsyncCallback callback, object state) { bool flag = this.throttle.EnterAsync(timeout, callback, state); if (!flag) { this.TraceWarning(); } return(flag); }
public bool EnterAsync(TimeSpan timeout, FastAsyncCallback callback, object state) { AsyncWaitHandle item = null; lock (this.ThisLock) { if (this.aborted) { throw Fx.Exception.AsError(this.CreateObjectAbortedException()); } if (this.count < this.maxCount) { this.count++; return true; } item = new AsyncWaitHandle(); this.Waiters.Enqueue(item); } return item.WaitAsync(EnteredAsyncCallback, new EnterAsyncData(this, item, callback, state), timeout); }
public bool EnterAsync(TimeSpan timeout, FastAsyncCallback callback, object state) { AsyncWaitHandle item = null; lock (this.ThisLock) { if (this.aborted) { throw Fx.Exception.AsError(this.CreateObjectAbortedException()); } if (this.count < this.maxCount) { this.count++; return(true); } item = new AsyncWaitHandle(); this.Waiters.Enqueue(item); } return(item.WaitAsync(EnteredAsyncCallback, new EnterAsyncData(this, item, callback, state), timeout)); }
bool AcquireLockAsync(TimeSpan timeout, bool isAbortPriority, bool skipPause, ref bool ownsLock, FastAsyncCallback callback, object state) { Fx.Assert(!ownsLock, "We should never call acquire if we already think we own the lock."); // We cannot just hand off the lock if we are in a handler thread // because this might eventually go async (during the operation) // and we could have multiple operations occurring concurrently. if (!this.executorLock.TryEnter(ref ownsLock)) { Fx.Assert(!ownsLock, "This should always match the return of TryEnter and is only useful in light of exceptions"); bool incrementedActiveOperations = false; bool decrementActiveOperations = true; object lockToken = null; try { lock (this.activeOperationsLock) { try { } finally { this.activeOperations++; incrementedActiveOperations = true; } // An exception occuring before we call PauseScheduler causes no issues/----s since // we'll just cleanup activeOperations and be in the same state as when AcquireLock // was called. if (!skipPause) { this.Controller.RequestPause(); } this.executorLock.SetupWaiter(isAbortPriority, ref lockToken); } // If we get the lock here then we should decrement, otherwise // it is up to the lock acquired callback decrementActiveOperations = this.executorLock.EnterAsync(timeout, ref lockToken, ref ownsLock, lockAcquiredAsyncCallback, new AcquireLockAsyncData(this, callback, state)); return decrementActiveOperations; } finally { if (incrementedActiveOperations && decrementActiveOperations) { lock (this.activeOperationsLock) { this.activeOperations--; } } this.executorLock.CleanupWaiter(lockToken, ref ownsLock); } } else { return true; } }
bool AcquireLockAsync(TimeSpan timeout, ref bool ownsLock, FastAsyncCallback callback, object state) { return AcquireLockAsync(timeout, false, false, ref ownsLock, callback, state); }
public AsyncWaiterData(WorkflowExecutionLock owner, FastAsyncCallback callback, object state, object token) { this.Owner = owner; this.Callback = callback; this.State = state; this.Token = token; }
public bool EnterAsync(TimeSpan timeout, ref object token, ref bool ownsLock, FastAsyncCallback callback, object state) { Fx.Assert(!ownsLock, "We should never attempt to get the lock if we think we own it."); Fx.Assert(callback != null, "must have a non-null call back for async purposes"); Fx.Assert(token is AsyncWaitHandle, "The token must be an AsyncWaitHandle."); AsyncWaitHandle waitHandle = null; lock (ThisLock) { if (!this.owned) { try { } finally { this.owned = true; ownsLock = true; } return true; } waitHandle = (AsyncWaitHandle)token; } bool result = false; if (waitHandle.WaitAsync(asyncWaiterSignaledCallback, new AsyncWaiterData(this, callback, state, waitHandle), timeout)) { Fx.Assert(!this.Waiters.Contains(waitHandle), "We should not have this wait handle in the list."); // Since the waiter is only signaled when they own the lock we won't have // to set owned to true if this returns true. owned was never set to false // by Exit in this case. ownsLock = true; result = true; } token = null; return result; }
bool AcquireLockWithoutPause() { if (!this.instance.IsHandlerThread && !this.ownsLock) { if (onLockAcquired == null) { onLockAcquired = new FastAsyncCallback(OnLockAcquired); } if (this.instance.AcquireLockAsync(this.timeoutHelper.RemainingTime(), false, true, ref this.ownsLock, onLockAcquired, this)) { return HandleLockAcquired(); } else { return false; } } else { return HandleLockAcquired(); } }
public AcquireLockAsyncData(WorkflowServiceInstance instance, FastAsyncCallback callback, object state) { this.instance = instance; this.callback = callback; this.state = state; }
public bool EnterAsync(TimeSpan timeout, FastAsyncCallback callback, object state) { bool flag = this.throttle.EnterAsync(timeout, callback, state); if (!flag) { this.TraceWarning(); } return flag; }
public EnterAsyncData(ThreadNeutralSemaphore semaphore, AsyncWaitHandle waiter, FastAsyncCallback callback, object state) { this.Waiter = waiter; this.Semaphore = semaphore; this.Callback = callback; this.State = state; }
private bool AcquireLockAsync(TimeSpan timeout, bool isAbortPriority, bool skipPause, ref bool ownsLock, FastAsyncCallback callback, object state) { if (!this.executorLock.TryEnter(ref ownsLock)) { bool flag = false; bool flag2 = true; object token = null; try { lock (this.activeOperationsLock) { try { } finally { this.activeOperations++; flag = true; } if (!skipPause) { base.Controller.RequestPause(); } this.executorLock.SetupWaiter(isAbortPriority, ref token); } return this.executorLock.EnterAsync(timeout, ref token, ref ownsLock, lockAcquiredAsyncCallback, new AcquireLockAsyncData(this, callback, state)); } finally { if (flag && flag2) { lock (this.activeOperationsLock) { this.activeOperations--; } } this.executorLock.CleanupWaiter(token, ref ownsLock); } } return true; }
bool WaitForStateLockAsync(TimeSpan timeout, FastAsyncCallback callback, object state) { return(this.stateLock.EnterAsync(timeout, callback, state)); }
public bool EnterAsync(TimeSpan timeout, FastAsyncCallback callback, object state) { bool success = this.throttle.EnterAsync(timeout, callback, state); if (!success) { TraceWarning(); } return success; }
bool WaitForStateLockAsync(TimeSpan timeout, FastAsyncCallback callback, object state) { return this.stateLock.EnterAsync(timeout, callback, state); }
public bool EnterAsync(TimeSpan timeout, FastAsyncCallback callback, object state) { bool flag; lock (this.ThisLock) { if (!this.aborted) { if (this.count >= this.maxCount) { AsyncWaitHandle asyncWaitHandle = new AsyncWaitHandle(); this.Waiters.Enqueue(asyncWaitHandle); return asyncWaitHandle.WaitAsync(ThreadNeutralSemaphore.EnteredAsyncCallback, new ThreadNeutralSemaphore.EnterAsyncData(this, asyncWaitHandle, callback, state), timeout); } else { ThreadNeutralSemaphore threadNeutralSemaphore = this; threadNeutralSemaphore.count = threadNeutralSemaphore.count + 1; flag = true; } } else { throw Fx.Exception.AsError(this.CreateObjectAbortedException()); } } return flag; }
private bool AcquireLockWithoutPause() { if (this.instance.IsHandlerThread || this.ownsLock) { return this.HandleLockAcquired(); } if (onLockAcquired == null) { onLockAcquired = new FastAsyncCallback(WorkflowServiceInstance.WaitForCanPersistAsyncResult.OnLockAcquired); } return (this.instance.AcquireLockAsync(this.timeoutHelper.RemainingTime(), false, true, ref this.ownsLock, onLockAcquired, this) && this.HandleLockAcquired()); }
public bool EnterAsync(TimeSpan timeout, ref object token, ref bool ownsLock, FastAsyncCallback callback, object state) { AsyncWaitHandle handle = null; lock (this.ThisLock) { if (!this.owned) { try { } finally { this.owned = true; ownsLock = true; } return true; } handle = (AsyncWaitHandle) token; } bool flag = false; if (handle.WaitAsync(asyncWaiterSignaledCallback, new AsyncWaiterData(this, callback, state, handle), timeout)) { ownsLock = true; flag = true; } token = null; return flag; }