Pathfinding.Path.ReleaseSilent C# (CSharp) Method

ReleaseSilent() public method

public ReleaseSilent ( System o ) : void
o System
return void
		public void ReleaseSilent (System.Object o) {

			if (o == null) throw new System.ArgumentNullException ("o");

			for (int i=0;i<claimed.Count;i++) {
				// Need to use ReferenceEquals because it might be called from another thread
				if (System.Object.ReferenceEquals (claimed[i], o)) {
					claimed.RemoveAt (i);
#if ASTAR_POOL_DEBUG
					claimInfo.RemoveAt (i);
#endif
					if (releasedNotSilent && claimed.Count == 0) {
						Recycle ();
					}
					return;
				}
			}
			if (claimed.Count == 0) {
				throw new System.ArgumentException ("You are releasing a path which is not claimed at all (most likely it has been pooled already). " +
					"Are you releasing the path with the same object ("+o+") twice?");
			}
			throw new System.ArgumentException ("You are releasing a path which has not been claimed with this object ("+o+"). " +
				"Are you releasing the path with the same object twice?");
		}

Usage Example

        /**
         * Returns all paths in the return stack.
         * Paths which have been processed are put in the return stack.
         * This function will pop all items from the stack and return them to e.g the Seeker requesting them.
         *
         * \param timeSlice Do not return all paths at once if it takes a long time, instead return some and wait until the next call.
         */
        public void ReturnPaths(bool timeSlice)
        {
            // Pop all items from the stack
            Path p = pathReturnStack.PopAll();

            if (pathReturnPop == null)
            {
                pathReturnPop = p;
            }
            else
            {
                Path tail = pathReturnPop;
                while (tail.next != null)
                {
                    tail = tail.next;
                }
                tail.next = p;
            }

            // Hard coded limit on 1.0 ms
            long targetTick = timeSlice ? System.DateTime.UtcNow.Ticks + 1 * 10000 : 0;

            int counter = 0;

            // Loop through the linked list and return all paths
            while (pathReturnPop != null)
            {
                //Move to the next path
                Path prev = pathReturnPop;
                pathReturnPop = pathReturnPop.next;

                // Remove the reference to prevent possible memory leaks
                // If for example the first path computed was stored somewhere,
                // it would through the linked list contain references to all comming paths to be computed,
                // and thus the nodes those paths searched.
                // That adds up to a lot of memory not being released
                prev.next = null;

                //Return the path
                prev.ReturnPath();

                // Will increment to Returned
                // However since multithreading is annoying, it might be set to ReturnQueue for a small time until the pathfinding calculation
                // thread advanced the state as well
                prev.AdvanceState(PathState.Returned);

                prev.ReleaseSilent(pathsClaimedSilentlyBy);

                counter++;
                // At least 5 paths will be returned, even if timeSlice is enabled
                if (counter > 5 && timeSlice)
                {
                    counter = 0;
                    if (System.DateTime.UtcNow.Ticks >= targetTick)
                    {
                        return;
                    }
                }
            }
        }
All Usage Examples Of Pathfinding.Path::ReleaseSilent