Example #1
0
 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));
 }
Example #2
0
 private void action_Finishing(IExecutive exec, object userData)
 {
     if (--m_remaining == 0)
     {
         m_myIDEC.Resume();
     }
 }
Example #3
0
 /// <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.
             }
         }
     }
 }
Example #4
0
 void myPfcec_EntryAdded(object key, object value)
 {
     if (key.Equals(m_sequenceKey))
     {
         m_idec.Resume();
     }
 }
Example #5
0
 void m_exchange_TupleTaken(ITupleSpace space, ITuple tuple)
 {
     if (tuple.Equals(m_tuple))
     {
         m_exchange.TupleTaken -= m_myEvent;
         m_idec.Resume();
     }
 }
Example #6
0
                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);
                }
Example #7
0
        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;
        }
Example #8
0
 /// <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();
     }
 }
Example #9
0
            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();
                    }
                }
            }
Example #10
0
 /// <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.
         }
     }
 }
Example #11
0
        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);
        }