public void Tick() { Assert.That(_isAsync); if (!_asyncQueue.IsEmpty()) { // Cache the callback list to allow handlers to be added from within callbacks using (var block = DisposeBlock.Spawn()) { var subscriptions = block.SpawnList <SignalSubscription>(); subscriptions.AddRange(_subscriptions); // Cache the signals so that if the signal is fired again inside the handler that it // is not executed until next frame var signals = block.SpawnList <object>(); signals.AddRange(_asyncQueue); _asyncQueue.Clear(); for (int i = 0; i < signals.Count; i++) { FireInternal(subscriptions, signals[i]); } } } }
static void OnDespawned(DisposeBlock that) { if (that._disposables != null) { // Dispose in reverse order since usually that makes the most sense for (int i = that._disposables.Count - 1; i >= 0; i--) { that._disposables[i].Dispose(); } ListPool <IDisposable> .Instance.Despawn(that._disposables); that._disposables = null; } if (that._objectPoolPairs != null) { // Dispose in reverse order since usually that makes the most sense for (int i = that._objectPoolPairs.Count - 1; i >= 0; i--) { var pair = that._objectPoolPairs[i]; pair.Pool.Despawn(pair.Object); } ListPool <SpawnedObjectPoolPair> .Instance.Despawn(that._objectPoolPairs); that._objectPoolPairs = null; } }
public void Fire(object signal) { Assert.That(signal.GetType().DerivesFromOrEqual(_bindingId.Type)); if (_isAsync) { _asyncQueue.Add(signal); } else { // Cache the callback list to allow handlers to be added from within callbacks using (var block = DisposeBlock.Spawn()) { var subscriptions = block.SpawnList <SignalSubscription>(); subscriptions.AddRange(_subscriptions); FireInternal(subscriptions, signal); } } }
static void OnSpawned(DisposeBlock that) { Assert.IsNull(that._disposables); Assert.IsNull(that._objectPoolPairs); }