コード例 #1
0
        private void DoRollback(IResourceRequest request)
        {
            // ReSharper disable once PossibleUnintendedReferenceComparison (Intended reference comparison.)
            if (request.ResourceObtained != this)
            {
                throw new ResourceMismatchException(request,
                                                    this,
                                                    ResourceMismatchException.MismatchType.UnReserve);
            }

            Substance addBackIn = (Substance)((Substance)m_material).MaterialType.CreateMass(request.QuantityObtained, m_material.Temperature);
            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            Substance material = (Substance)m_material;

            //if ( material != null ) {
            material.Add(addBackIn);

            /*} else if ( m_material is Mixture ) {
             *      ((Mixture)m_material).AddMaterial(addBackIn);
             * } else {
             *      Debug.Assert(false,"Unknown IMaterial type : " + m_material.GetType().Name);
             * }*/
            request.ResourceObtained     = null;
            request.ResourceObtainedFrom = null;
            request.QuantityObtained     = 0;
        }
コード例 #2
0
 private void TellerPoolOnResourceReleased(IResourceRequest irr, IResource resource)
 {
     if (m_tellerPool.Acquire(m_tellerRequest, false))
     {
         m_tellerPool.ResourceReleased -= TellerPoolOnResourceReleased;
     }
 }
コード例 #3
0
ファイル: Tracking.cs プロジェクト: sjvannTMU/Sage
        private void LogEvent(IResource resource, IResourceRequest irr, ResourceAction action)
        {
            if (s_diagnostics)
            {
                _Debug.WriteLine(m_model.Executive.Now + " : Resource Tracker " + m_target.Name
                                 + " (" + m_target.Guid + ") logged " + action
                                 + " with " + irr.QuantityDesired + ".");
            }
            ResourceEventRecord rer = new ResourceEventRecord(m_model.Executive.Now, resource, irr, action);

            if (m_rerFilter == null || m_rerFilter(rer))
            {
                m_record.Add(rer);
                if (s_diagnostics)
                {
                    _Debug.WriteLine("\tLogged.");
                }
            }
            else
            {
                if (s_diagnostics)
                {
                    _Debug.WriteLine("\tFiltered out.");
                }
            }
        }
コード例 #4
0
ファイル: ResourceManager.cs プロジェクト: sjvannTMU/Sage
 /// <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.
             }
         }
     }
 }
コード例 #5
0
        /// <summary>
        /// Acquires a resource according to the specified resource request, either blocking until successful, or
        /// returning &lt;null&gt; if the resource is not immediately available.
        /// </summary>
        /// <param name="resourceRequest">The IResourceRequest that specifies the criteria by which to select the resource.</param>
        /// <param name="blockAwaitingAcquisition">If true, request will suspend until granted. If false, will return false if unable to fulfill.</param>
        /// <returns>True if granted, false if not granted.</returns>
        public bool Acquire(IResourceRequest resourceRequest, bool blockAwaitingAcquisition)
        {
            if (blockAwaitingAcquisition)
            {
                IDetachableEventController dec = Model.Executive.CurrentEventController;
                if (dec == null)
                {
                    throw new ApplicationException("Someone tried to call Acquire(..., true) while not in a detachable event. This is not allowed.");
                }

                dec.SetAbortHandler(resourceRequest.AbortHandler);
                resourceRequest.ResourceRequestAborting += m_onResourceRequestAborting;

                while (true)
                {
                    if (Acquire(resourceRequest))
                    {
                        break;
                    }
                    m_waiters.Add(dec);
                    dec.Suspend();
                    dec.ClearAbortHandler();
                }
                return(true);
            }
            else
            {
                return(Acquire(resourceRequest));
            }
        }
コード例 #6
0
ファイル: ResourceManager.cs プロジェクト: sjvannTMU/Sage
        /// <summary>
        /// Attempts to acquire a proscribed quantity of a resource in this resource pool. If the
        /// resource has already been reserved under this resourceRequest, it simply acquires that
        /// resource. If no resource has been reserved, then the best available resource will be
        /// reserved, and then acquired.
        /// </summary>
        /// <param name="resourceRequest">The resource request under which the reservation is to take
        /// place, and describing the resources desired.</param>
        /// <param name="blockAwaitingAcquisition">If true, blocks until resource is acquired.</param>
        /// <returns>true if the acquisition was successful.</returns>
        public bool Acquire(IResourceRequest resourceRequest, bool blockAwaitingAcquisition)
        {
            if (s_diagnostics)
            {
                _Debug.WriteLine(Name + " servicing request to acquire (" + (blockAwaitingAcquisition?"with":"without") + " block) " + resourceRequest.QuantityDesired + " units of " + resourceRequest);
            }

            if (resourceRequest.RequiredResource != null)
            {
                _Debug.Assert(false, "Explicit targeting of resources not yet implemented.");
                // TODO: Explicit targeting of resources and keying of requests not yet implemented.
            }

            if (blockAwaitingAcquisition)
            {
                bool acquired = AcquireWithWait(resourceRequest);
                return(acquired);
            }

            bool ableToReserve = ReserveBestResource(resourceRequest);

            if (ableToReserve)
            {
                lock (resourceRequest.ResourceObtained) {
                    IResource rsc = resourceRequest.ResourceObtained;
                    rsc.Acquire(resourceRequest);
                    resourceRequest.ResourceObtainedFrom = this;
                    ResourceAcquired?.Invoke(resourceRequest, resourceRequest.ResourceObtained);
                }
            }
            return(ableToReserve);
        }
コード例 #7
0
ファイル: Tracking.cs プロジェクト: sjvannTMU/Sage
 private void target_ReleasedEvent(IResourceRequest irr, IResource resource)
 {
     if (_allEnabled && m_enabled)
     {
         LogEvent(resource, irr, ResourceAction.Released);
     }
 }
コード例 #8
0
ファイル: ResourceManager.cs プロジェクト: sjvannTMU/Sage
        /// <summary>
        /// Acquires the resource and quantity specifed by the resource request, blocking
        /// until it can return successfully.
        /// </summary>
        /// <param name="request">The resource request that describes the desired resource and quantity.</param>
        /// <returns>Always true.</returns>
        protected bool AcquireWithWait(IResourceRequest request)
        {
            IDetachableEventController dec = Model.Executive.CurrentEventController;

            if (dec == null)
            {
                throw new ApplicationException("Someone tried to call AcquireWithWait() while not in a detachable event. This is not allowed.");
            }

            dec.SetAbortHandler(request.AbortHandler);
            request.ResourceRequestAborting += m_onResourceRequestAborting;
            while (!Acquire(request, false))
            {
                m_waiters.Add(request, dec);
                dec.Suspend();
                dec.ClearAbortHandler();
            }
            if (request.ResourceObtained != null)
            {
                ResourceAcquired?.Invoke(request, request.ResourceObtained);
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #9
0
        private bool AttemptExecution(IResourceRequest request)
        {
            double proposedNewAmountAvailable = m_material.Mass - request.QuantityDesired;

            if (proposedNewAmountAvailable < (-PermissibleOverbook) || proposedNewAmountAvailable > m_capacity)
            {
                return(false);
            }
            request.QuantityObtained = request.QuantityDesired;
            request.ResourceObtained = this;
            Substance material = m_material as Substance;

            if (material != null)
            {
                material.Remove(request.QuantityDesired);
            }
            else if (m_material is Mixture)
            {
                ((Mixture)m_material).RemoveMaterial(request.QuantityDesired);
            }
            else
            {
                Debug.Assert(false, "Unknown IMaterial type : " + m_material.GetType().Name);
            }
            request.ResourceObtainedFrom = this;
            return(true);
        }
コード例 #10
0
ファイル: Tracking.cs プロジェクト: sjvannTMU/Sage
 private void m_target_ReleasedEvent(IResourceRequest irr, IResource resource)
 {
     if (GlobalEnabled && Enabled)
     {
         LogEvent(resource, irr, ResourceAction.Released);
     }
 }
コード例 #11
0
 /// <summary>
 /// Creates a new instance of the <see cref="T:TerminalResourceRequestAbortedWarning"/> class.
 /// </summary>
 /// <param name="exec">The executive under whose control this warning occurred.</param>
 /// <param name="mgr">The Resource Manager from which the resource was obtained.</param>
 /// <param name="req">The request through which the resource was obtained.</param>
 /// <param name="idec">The <see cref="Highpoint.Sage.SimCore.IDetachableEventController"/> that controls the thread in which the resource was last manipulated.</param>
 public TerminalResourceRequestAbortedWarning(IExecutive exec, IResourceManager mgr, IResourceRequest req, IDetachableEventController idec)
 {
     m_idec          = idec;
     ResourceRequest = req;
     ResourceManager = mgr;
     m_exec          = exec;
     Narrative       = GetNarrative();
 }
コード例 #12
0
        private static bool ReserveAllWithWait(ref IResourceRequest[] requests)
        {
            #region >>> Acquire all resources without deadlock. <<<
            // We will maintain a queue of resource requirements. The first one in the
            // queue is reserved with a wait-lock, and subsequent RP's are reserved
            // without a wait lock. If a reservation succeeds, then the RP is requeued
            // at the end of the queue. If it fails, then all RP's in the queue are
            // unreserved, and the next attempt begins at the beginning of the queue.
            // -
            // Note that in this next attempt, the one for whom reservation has most
            // recently failed is still at the head of the queue, and is the one that
            // is reserved with a wait-lock.

            Hashtable successes = new Hashtable();
            Queue     rscQueue  = new Queue();

            #region >>> Load the queue with the resource requests. <<<
            foreach (IResourceRequest irr in requests)
            {
                rscQueue.Enqueue(irr);
            }

            #endregion

            bool nextIsMaster = true;
            while (rscQueue.Count > 0)
            {
                IResourceRequest rp = (IResourceRequest)rscQueue.Peek();
                if (successes.Contains(rp))
                {
                    break;                                           // We've acquired all of them.
                }
                bool rpSucceeded = rp.Reserve(null, nextIsMaster);
                nextIsMaster = !rpSucceeded;                 // If failed, the next time through, the head of the q will be master.
                if (!rpSucceeded)
                {
                    foreach (IResourceRequest reset in rscQueue)
                    {
                        if (successes.Contains(rp))
                        {
                            reset.Unreserve();
                        }
                    }
                    successes.Clear();
                }
                else
                {
                    rscQueue.Enqueue(rscQueue.Dequeue());                     // Send the successful request to the back of the queue.
                    successes.Add(rp, rp);
                }
            }
//			if ( rscQueue.Count == 0 ) {
//				_Debug.WriteLine("No resources were requested.");
//			}
            #endregion

            return(true);
        }
コード例 #13
0
ファイル: Tracking.cs プロジェクト: sjvannTMU/Sage
        private void LogEvent(IResource resource, IResourceRequest irr, ResourceAction action)
        {
            ResourceEventRecord rer = new ResourceEventRecord(m_model.Executive.Now, resource, irr, action);

            if (m_rerFilter != null && m_rerFilter(rer))
            {
                m_record.Add(rer);
            }
        }
コード例 #14
0
            public ResourceUser(IModel model, string name, Guid guid, SelfManagingResource smr)
            {
                InitializeIdentity(model, name, null, guid);

                m_irr             = new SimpleResourceRequest(1.0, smr);
                m_model.Starting += new ModelEvent(ScheduleMyResourceAction);

                IMOHelper.RegisterWithModel(this);
            }
コード例 #15
0
 /// <summary>
 /// Replicates the specified requests.
 /// </summary>
 /// <param name="requests">The requests.</param>
 /// <returns></returns>
 public static IResourceRequest[] Replicate(ref IResourceRequest[] requests)
 {
     IResourceRequest[] replicates = new IResourceRequest[requests.Length];
     for (int i = 0; i < requests.Length; i++)
     {
         replicates[i] = requests[i].Replicate();
     }
     return(replicates);
 }
コード例 #16
0
ファイル: TestServers.cs プロジェクト: stuarthillary/Sage-1
        public void TestResourceServerComplexDemands()
        {
            m_noAdmitCount = 0;
            m_admitCount   = 0;

            m_model = new Model();
            ((Model)m_model).RandomServer = new Randoms.RandomServer(54321, 100);

            ItemSource factory = CreatePatientGenerator("Patient_", 50, 5.0, 3.0);
            Queue      queue   = new Queue(m_model, "TestQueue", Guid.NewGuid());

            ConnectorFactory.Connect(factory.Output, queue.Input);

            NormalDistribution   dist    = new NormalDistribution(m_model, "SvcDistribution", Guid.NewGuid(), 240.0, 45.0);
            IPeriodicity         per     = new Periodicity(dist, Periodicity.Units.Minutes);
            SelfManagingResource nursing = new SelfManagingResource(m_model, "Nursing", Guid.NewGuid(), 7.0, 7.0, false, false, true);
            SelfManagingResource clerks  = new SelfManagingResource(m_model, "Clerks", Guid.NewGuid(), 6.0, 6.0, false, false, true);
            SelfManagingResource doctors = new SelfManagingResource(m_model, "Doctors", Guid.NewGuid(), 2.0, 2.0, false, false, true);

            MultiResourceTracker mrt = new MultiResourceTracker(m_model);

            mrt.Filter = ResourceEventRecordFilters.AcquireAndReleaseOnly;
            //mrt.Filter = ResourceTracker.Filters.AllEvents;
            mrt.AddTargets(nursing, clerks, doctors);

            IResourceRequest[] demands = new IResourceRequest[] {
                new SimpleResourceRequest(.20, nursing),
                new SimpleResourceRequest(.15, clerks),
                new SimpleResourceRequest(.05, doctors)
            };

            ResourceServer rs = new ResourceServer(m_model, "RscSvr", Guid.NewGuid(), per, demands);

            rs.PlaceInService();
            ConnectorFactory.Connect(queue.Output, rs.Input);

            factory.Output.PortDataPresented += new PortDataEvent(FactoryOutput_PortDataPresented);
            queue.LevelChangedEvent          += new QueueLevelChangeEvent(Queue_LevelChangedEvent);
            rs.ServiceBeginning += new ServiceEvent(Server_ServiceBeginning);
            rs.ServiceCompleted += new ServiceEvent(Server_ServiceCompleted);

            m_model.Start();

//          string dataFileName = Highpoint.Sage.Utility.DirectoryOperations.GetAppDataDir() + @"Data.csv";
//			System.IO.TextWriter tw = new System.IO.StreamWriter(dataFileName);
//			foreach ( ResourceEventRecord rer in mrt ) {
//				tw.WriteLine(rer.When.ToLongTimeString()+","
//					+rer.Resource.Name+","
//					+rer.Action.ToString()+","
//					+rer.Available	);
//			}
//			tw.Close();
//			System.Diagnostics.Process.Start("excel.exe","\""+dataFileName+"\"");

            Console.WriteLine(new CSVDumper(mrt, new CompoundComparer(ResourceEventRecord.ByAction(false), ResourceEventRecord.ByTime(false))).ToString());
        }
コード例 #17
0
ファイル: Resource.cs プロジェクト: JustinBritt/Sage
        public void Release(IResourceRequest request)
        {
            IResource originator = m_wrappedByWhom ?? this;

            RequestEvent?.Invoke(request, originator);
            lock (this) {
                AttemptReturnToService(request);
                ReleasedEvent?.Invoke(request, originator);
            }
        }
コード例 #18
0
ファイル: Resource.cs プロジェクト: JustinBritt/Sage
        public void Unreserve(IResourceRequest request)
        {
            IResource originator = m_wrappedByWhom ?? this;

            RequestEvent?.Invoke(request, originator);
            lock (this) {
                AttemptReturnToService(request);
                request.ResourceObtainedFrom = null;
            }
            UnreservedEvent?.Invoke(request, originator);
        }
コード例 #19
0
ファイル: Resource.cs プロジェクト: JustinBritt/Sage
        private void AttemptReturnToService(IResourceRequest request)
        {
            if (!Equals(request.ResourceObtained, m_wrappedByWhom))
            {
                throw new ResourceMismatchException(request,
                                                    m_wrappedByWhom,
                                                    ResourceMismatchException.MismatchType.UnReserve);
            }

            Available += (IsAtomic?Capacity:request.QuantityObtained);
            request.ResourceObtained = null;
            request.QuantityObtained = 0;
        }
コード例 #20
0
ファイル: ResourceManager.cs プロジェクト: sjvannTMU/Sage
 public void Add(IResourceRequest rreq, IDetachableEventController idec)
 {
     if (!m_supportsPriorities)
     {
         base.Add(idec);
     }
     else
     {
         rreq.PriorityChangeEvent += m_rreqPriorityChangeEvent;
         m_dirty = true;                     // TODO: Not necessarily
         base.Add(new RscWaiterListEntry(rreq, idec, m_seqNum++));
     }
 }
コード例 #21
0
            private void AcqireResource(IModel theModel)
            {
                Console.WriteLine("Acquiring the resource at " + theModel.Executive.Now);
                m_rscReq = new SimpleResourceRequest(1.0, m_smr);
                m_smr.Acquire(m_rscReq, false);

                ExecEventReceiver eer      = new ExecEventReceiver(ReleaseResource);
                DateTime          when     = theModel.Executive.Now + TimeSpan.FromMinutes(10.0);
                double            priority = 0.0;
                ExecEventType     eet      = ExecEventType.Synchronous;

                theModel.Executive.RequestEvent(eer, when, priority, null, eet);
            }
コード例 #22
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();
     }
 }
コード例 #23
0
 /// <summary>
 /// Reserves the specified request. Removes it from availability, but not from the pool. This is typically an intermediate state held during resource negotiation.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <returns><c>true</c> if the resource was successfully reserved, <c>false</c> otherwise.</returns>
 public bool Reserve(IResourceRequest request)
 {
     ResourceRequested?.Invoke(request, this);
     RequestEvent?.Invoke(request, this);
     lock (this) {
         if (AttemptExecution(request))
         {
             ReservedEvent?.Invoke(request, this);
             ResourceReserved?.Invoke(request, this);
             return(true);
         }
         return(false);
     }
 }
コード例 #24
0
ファイル: ResourceLoader.cs プロジェクト: yika-aixi/tlplib
        static IEnumerator waitForLoadCoroutine <A>(
            IResourceRequest request, Action <Either <ErrorMsg, A> > whenDone, string path
            ) where A : Object
        {
            yield return(request.yieldInstruction);

            if (request.asset is A a)
            {
                whenDone(a);
            }
            else
            {
                whenDone(notFound <A>(path));
            }
        }
コード例 #25
0
        /// <summary>
        /// Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
        /// </summary>
        /// <param name="obj">An object to compare with this instance.</param>
        /// <returns>A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes <paramref name="obj" /> in the sort order. Zero This instance occurs in the same position in the sort order as <paramref name="obj" />. Greater than zero This instance follows <paramref name="obj" /> in the sort order.</returns>
        public int CompareTo(object obj)
        {
            IResourceRequest irr = (IResourceRequest)obj;
            int retval           = Comparer.Default.Compare(Priority, irr.Priority);

            if (retval == 0)
            {
                retval = Comparer.Default.Compare(QuantityDesired, irr.QuantityDesired);
            }
            if (retval == 0)
            {
                retval = -1;
            }
            return(retval);
        }
コード例 #26
0
ファイル: Tracking.cs プロジェクト: sjvannTMU/Sage
 /// <summary>
 /// Constructs a record of a resource transaction.
 /// </summary>
 /// <param name="when">The time (model time) that the transaction took place.</param>
 /// <param name="resource">The resource against which this transaction took place.</param>
 /// <param name="irr">The resource request that initiated this transaction.</param>
 /// <param name="action">The type of <see cref="Highpoint.Sage.Resources.ResourceAction"/> that took place.</param>
 public ResourceEventRecord(DateTime when, IResource resource, IResourceRequest irr, ResourceAction action)
 {
     m_resource         = resource;
     ResourceGuid       = resource.Guid;
     When               = when;
     m_quantityDesired  = irr.QuantityDesired;
     m_quantityObtained = irr.QuantityObtained;
     m_capacity         = resource.Capacity;
     Available          = resource.Available;
     Requester          = irr.Requester;
     RequesterGuid      = irr.Requester?.Guid ?? Guid.Empty;
     Action             = action;
     m_tag              = null;
     m_tagGuid          = Guid.Empty;
     SerialNumber       = Utility.SerialNumberService.GetNext();
 }
コード例 #27
0
ファイル: Resource.cs プロジェクト: JustinBritt/Sage
        public bool Reserve(IResourceRequest request)
        {
            IResource originator = m_wrappedByWhom ?? this;

            RequestEvent?.Invoke(request, originator);
            bool bSuccess;

            lock (this) {
                bSuccess = AttemptRemovalFromService(request);
                if (bSuccess)
                {
                    ReservedEvent?.Invoke(request, originator);
                }
            }
            return(bSuccess);
        }
コード例 #28
0
 /// <summary>
 /// Acquires the specified request. Removes it from availability and from the resource pool.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <returns><c>true</c> if if the resource was successfully acquired, <c>false</c> otherwise.</returns>
 public bool Acquire(IResourceRequest request)
 {
     ResourceRequested?.Invoke(request, this);
     RequestEvent?.Invoke(request, this);
     lock (this) {
         if (AttemptExecution(request))
         {
             AcquiredEvent?.Invoke(request, this);
             ResourceAcquired?.Invoke(request, this);
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
コード例 #29
0
ファイル: TestResources.cs プロジェクト: stuarthillary/Sage-1
        private void TryAcquire(SelfManagingResource rsc, IResourceRequest irr, bool expectSuccess)
        {
            string result = "Acqusition of " + rsc.Name + " using key " + irr.Key.ToString() + " expected to " + (expectSuccess?"succeed":"fail") + ".";

            if (rsc.Acquire(irr, false) == expectSuccess)
            {
                if (expectSuccess)
                {
                    rsc.Release(irr);
                }
                Console.WriteLine("Sub-test passed : " + result);
            }
            else
            {
                _Debug.Assert(false, "Access Regulation", "Sub-test failed : " + result);
            }
        }
コード例 #30
0
ファイル: ResourceManager.cs プロジェクト: sjvannTMU/Sage
        /// <summary>
        /// Attempts to reserve a proscribed quantity of a particular resource in this resource pool. This
        /// removes the resource quantity from availability for further reservation &amp; acquisition.
        /// </summary>
        /// <param name="resourceRequest">The resource request under which the reservation is to take place.</param>
        /// <param name="blockAwaitingAcquisition">If true, blocks until resource is reserved.</param>
        /// <returns>true if the reservation was successful.</returns>
        public bool Reserve(IResourceRequest resourceRequest, bool blockAwaitingAcquisition)
        {
            if (s_diagnostics)
            {
                _Debug.WriteLine(Name + " servicing request to reserve (" + (blockAwaitingAcquisition?"with":"without") + " block) " + resourceRequest.QuantityDesired + " units of " + resourceRequest);
            }

            if (resourceRequest.RequiredResource != null)
            {
                _Debug.Assert(false, GetType().FullName + " does not support explicit targeting of resources.");
            }

            if (blockAwaitingAcquisition)
            {
                return(ReserveWithWait(resourceRequest));
            }

            ReserveBestResource(resourceRequest);
            return(resourceRequest.ResourceObtained != null);
        }
コード例 #31
0
ファイル: Mission.cs プロジェクト: qrunner/Default
 public void RemoveResourceRequest(IResourceRequest resourceRequest)
 {
     RemoveItem(ResourceRequests, (ResourceRequest) resourceRequest);
 }