protected void SetParent(RoutineBase newParent) { if (parent == newParent) { return; } if (parent != null) { Assert.IsTrue(parent.children.Contains(this)); parent.children.Remove(this); } parent = newParent; if (newParent != null) { manager = parent.manager; newParent.children.Add(this); } else { manager = null; } }
protected virtual void Reset() { Stop(); state = State.NotStarted; if (stateMachine != null) { stateMachinePool.Release(stateMachine); stateMachine = null; } parent = null; manager = null; }
private static void CollectAwaitingRoutines(RoutineBase routine, List <RoutineBase> awaitingRoutines) { var isAwaiting = true; foreach (var child in routine.children) { if (child.IsRunning) { isAwaiting = false; CollectAwaitingRoutines(child, awaitingRoutines); } } if (isAwaiting) { awaitingRoutines.Add(routine); } }
private void Setup(bool yield, RoutineBase parent) { id = nextId++; SetParent(parent); state = yield ? State.Running : State.NotStarted; }
/// <summary> Release routine back to pool. </summary> public static void Release(RoutineBase routine) { routine.Reset(); pool.Release(routine); }