private void FutureComplete(IFuture f) { _queueFutures.Remove(f); if (_queueFutures.Count > 0) { if (_current == f) { _current = _queueFutures[0]; } } else { _current = null; } if (onFutureComplete != null) { onFutureComplete(f); } if (_current != null) { _current.Run(); } }
protected override void OnRun() { _delayFuture.AddListener(f => { if (f.isDone) { Complete(); } }); _timer = Timer.Create(_delay, () => { _delayFuture.Run(); }, null, true); }
public void AddFuture(IFuture future) { if (future.isDone || future.isCancelled || future.wasRun) { throw new Exception("future already run or completed"); } _queueFutures.Add(future); future.AddListener(FutureComplete); if (_queueFutures.Count == 1) { _current = future; future.Run(); } }
void CompleteFuture(IFuture future) { IFuture nextFuture = null; _compositeFutures.RemoveAt(0); if (_compositeFutures.Count > 0) { nextFuture = _compositeFutures[0]; } if (nextFuture == null) { Complete(); } else { nextFuture.Run(); } }