/** Adds a path to the pool. * This function should not be used directly. Instead use the Path.Claim and Path.Release functions. */ public static void Pool(Path path) { lock (pool) { if (path.pooled) { throw new System.ArgumentException("The path is already pooled."); } Stack <Path> poolStack; if (!pool.TryGetValue(path.GetType(), out poolStack)) { poolStack = new Stack <Path>(); pool[path.GetType()] = poolStack; } path.pooled = true; path.OnEnterPool(); poolStack.Push(path); } }
public static void Pool(Path path) { Dictionary <Type, Stack <Path> > pool = PathPool.pool; lock (pool) { Stack <Path> stack; if (path.pooled) { throw new ArgumentException("The path is already pooled."); } if (!PathPool.pool.TryGetValue(path.GetType(), out stack)) { stack = new Stack <Path>(); PathPool.pool[path.GetType()] = stack; } path.pooled = true; path.OnEnterPool(); stack.Push(path); } }
public static void Pool(Path path) { Dictionary <Type, Stack <Path> > obj = PathPool.pool; lock (obj) { if (((IPathInternals)path).Pooled) { throw new ArgumentException("The path is already pooled."); } Stack <Path> stack; if (!PathPool.pool.TryGetValue(path.GetType(), out stack)) { stack = new Stack <Path>(); PathPool.pool[path.GetType()] = stack; } ((IPathInternals)path).Pooled = true; ((IPathInternals)path).OnEnterPool(); stack.Push(path); } }
/// <summary> /// Adds a path to the pool. /// This function should not be used directly. Instead use the Path.Claim and Path.Release functions. /// </summary> public static void Pool(Path path) { #if !ASTAR_NO_POOLING lock (pool) { if (((IPathInternals)path).Pooled) { throw new System.ArgumentException("The path is already pooled."); } Stack <Path> poolStack; if (!pool.TryGetValue(path.GetType(), out poolStack)) { poolStack = new Stack <Path>(); pool[path.GetType()] = poolStack; } ((IPathInternals)path).Pooled = true; ((IPathInternals)path).OnEnterPool(); poolStack.Push(path); } #endif }