public Mixture Get(double kilograms) { if (m_waiters.Count > 0 || PeekMixture.Mass < kilograms) { m_waiters.Add(m_executive.CurrentEventController); do { m_getProcessor.Resume(); m_executive.CurrentEventController.Suspend(); } while (PeekMixture.Mass < kilograms); m_waiters.RemoveAt(0); m_getProcessor.Resume(); } return((Mixture)PeekMixture.RemoveMaterial(kilograms)); }
private void action_Finishing(IExecutive exec, object userData) { if (--m_remaining == 0) { m_myIDEC.Resume(); } }
/// <summary> /// Releases the resource held under this resource request back into the resource pool. /// </summary> /// <param name="resourceRequest">The resource request under which the resource has previously /// been acquired.</param> public void Release(IResourceRequest resourceRequest) { if (resourceRequest.ResourceObtained != null) { if (s_diagnostics) { string fromWhom = resourceRequest.ToString(); if (resourceRequest.ResourceObtained != null) { fromWhom = resourceRequest.ResourceObtained.Name; } _Debug.WriteLine(Name + " servicing request to release " + resourceRequest.QuantityDesired + " units of " + fromWhom); } IResource resourceReleased = resourceRequest.ResourceObtained; resourceRequest.ResourceObtained?.Release(resourceRequest); resourceRequest.Status = RequestStatus.Free; ResourceReleased?.Invoke(resourceRequest, resourceReleased); while (m_waiters.Count > 0) { IDetachableEventController dec = (IDetachableEventController)m_waiters[0]; m_waiters.RemoveAt(0); if (dec.IsWaiting()) { dec.Resume(); // We might be releasing all resources as a part of an abort. } } } }
void myPfcec_EntryAdded(object key, object value) { if (key.Equals(m_sequenceKey)) { m_idec.Resume(); } }
void m_exchange_TupleTaken(ITupleSpace space, ITuple tuple) { if (tuple.Equals(m_tuple)) { m_exchange.TupleTaken -= m_myEvent; m_idec.Resume(); } }
private void FinishRewiringDisposal(IExecutive exec, object userData) { IDetachableEventController plumbersIDEC = (IDetachableEventController)userData; Console.WriteLine("{0} : {1} is done fixing the disposal.", exec.Now, Name); plumbersIDEC.Resume(); Console.WriteLine("{0} : {1} is leaving.", exec.Now, Name); }
private void ProcessGetters(IExecutive exec, object userData) { m_getProcessor = exec.CurrentEventController; IDetachableEventController waiter = null; while (m_waiters.Count > 0 && m_waiters[0] != waiter) { waiter = m_waiters[0]; waiter.Resume(); m_getProcessor.Suspend(); } m_getFlushEventId = -1; m_getProcessor = s_dummyIdec; }
/// <summary> /// Releases the specified request. Returns it to availability and the resource pool. /// </summary> /// <param name="request">The request.</param> public void Release(IResourceRequest request) { lock (this) { DoRollback(request); ReleasedEvent?.Invoke(request, this); ResourceReleased?.Invoke(request, this); } while (m_waiters.Count > 0) { IDetachableEventController dec = (IDetachableEventController)m_waiters[0]; m_waiters.RemoveAt(0); dec.Resume(); } }
private void OnTransitionStateChanged(TransitionStateMachine tsm, object userData) { PfcExecutionContext completedStepsParentPfcec = (PfcExecutionContext)userData; if (completedStepsParentPfcec.Parent.Payload.Equals(m_rootStepEc) && tsm.GetState(completedStepsParentPfcec) == TransitionState.Inactive) { tsm.TransitionStateChanged -= m_onTransitionStateChanged; m_pendingActions.Remove(tsm.MyTransition.Parent); if (m_pendingActions.Count == 0) { m_idec.Resume(); } } }
/// <summary> /// Unreserves a quantity of resource from this pool that was previously reserved under the provided /// resource request. /// </summary> /// <param name="resourceRequest">The resource request under which some resource was previously reserved.</param> public void Unreserve(IResourceRequest resourceRequest) { if (s_diagnostics) { _Debug.WriteLine(Name + " servicing request to unreserve " + resourceRequest.QuantityDesired + " units of " + resourceRequest); } if (resourceRequest.ResourceObtained != null) { resourceRequest.ResourceObtained.Unreserve(resourceRequest); resourceRequest.Status = RequestStatus.Free; } while (m_waiters.Count > 0) { IDetachableEventController dec = (IDetachableEventController)m_waiters[0]; m_waiters.RemoveAt(0); if (dec.IsWaiting()) { dec.Resume(); // We might be releasing all resources as a part of an abort. } } }
private ITuple NonBlockingTake(object key) { ITuple tuple; lock ( m_ts ) { tuple = (ITuple)m_ts[key]; if (tuple != null) { m_ts.Remove(key); tuple.OnTaken(this); TupleTaken?.Invoke(this, tuple); IDetachableEventController blockedPoster = (IDetachableEventController)m_blockedPosters[tuple.Key]; if (blockedPoster != null) { m_blockedPosters.Remove(tuple.Key); blockedPoster.Resume(s_postPriority); } } } return(tuple); }