public void SubscriptionIsDisposedAfterAwaitableCompletes() { var storage = new InMemoryStorageEngine(); var os = ObjectStore.New(storage); var source = new Source <int>(); var awaitable = new CAwaitable(); var valueHolder = new ValueHolder <int>(); source.DisposeOn(awaitable).CallOnEvent(valueHolder.SetValue); source.Emit(1); valueHolder.Value.ShouldBe(1); os.Entangle(source); os.Entangle(awaitable); os.Entangle(valueHolder); os.Persist(); os = ObjectStore.Load(storage, true); source = os.Resolve <Source <int> >(); awaitable = os.Resolve <CAwaitable>(); valueHolder = os.Resolve <ValueHolder <int> >(); source.Emit(2); valueHolder.Value.ShouldBe(2); awaitable.SignalCompletion(); source.Emit(3); valueHolder.Value.ShouldBe(2); os.Persist(); os = ObjectStore.Load(storage, true); source = os.Resolve <Source <int> >(); awaitable = os.Resolve <CAwaitable>(); valueHolder = os.Resolve <ValueHolder <int> >(); source.Emit(4); valueHolder.Value.ShouldBe(2); }
private void ExecuteCallback() { Roots.UntangleAnonymously(this); _awaitable.SignalCompletion(); }
private void SignalAwaitable() { _awaitable.SignalCompletion(_toDeliver); _awaitable = null; _toDeliver = new CAppendOnlyList <T>(); }