public void SetState(T state, object obj = null) { if (_leaveFuture != null) { return; } if (_states.ContainsKey(currentState)) { if (currentState.Equals(state)) { _states[currentState].CallOnUpdate(obj); return; } _leaveFuture = _states[currentState].CallOnLeave(); } currentState = state; if (_states.ContainsKey(currentState)) { if (_leaveFuture != null) { _leaveFuture.AddListener(future => { _leaveFuture = null; _states[currentState].CallOnEnter(obj); }); } else { _states[currentState].CallOnEnter(obj); } } }
public void AddFuture(IFuture future) { if (wasRun || isDone || isCancelled || future.isDone || future.isCancelled) { return; } _futures.Add(future); future.AddListener(OnFutureComplete); }
public void AddFuture(IFuture future) { if (future == null) { return; } if (_futures.TryAdd(future, true)) { future.AddListener(InnerRemoveFuture); } }
private void Subscribe(IFuture target) { target.AddListener(future => { if (_watcher.futuresCount == 0 && future.isDone) { _processes.Clear(); isComplete = true; _loading = false; onProcessComplete?.Invoke(this); } }); }
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(); } }
protected void Next(IFuture obj) { if (isCancelled) { return; } if (enumerator.MoveNext() && enumerator.Current != null) { currentFuture = (IFuture)enumerator.Current; currentFuture.AddListener(Next); } else { Complete(); } }
IFuture <T> LoadAsync(string key, LoadingValueReference <T> loading_value_reference, CacheLoader <T> loader) { IFuture <T> loading_future = loading_value_reference.LoadFuture(key, loader); loading_future.AddListener(delegate() { try { T new_value = GetUninterruptibly(key, loading_value_reference, loading_future); // update loading future for the sake of other pending requests. loading_value_reference.Set(new_value); } catch (Exception exception) { MustLogger.ForCurrentProcess.Warn("Exception thrown during refresh", exception); } }, Executors.SameThreadExecutor()); return(loading_future); }