internal StreamQueue(Stream <T> stream)
        {
            stream.Subscribe(this, Handle);

            _awaitable = null;
            _toDeliver = new CAppendOnlyList <T>();
        }
Exemplo n.º 2
0
        public void AddBeforeAndAfterSerializationAndDeserialization()
        {
            var storage = new InMemoryStorageEngine();
            var os      = ObjectStore.New(storage);

            var l = new CAppendOnlyList <int> {
                1
            };

            l.ToArray()[0].ShouldBe(1);

            os.Entangle(l);
            os.Persist();

            os = ObjectStore.Load(storage, true);
            l  = os.Resolve <CAppendOnlyList <int> >();

            l.ToArray().Length.ShouldBe(1);
            l.ToArray()[0].ShouldBe(1);

            l.Add(2);

            l.ToArray().Length.ShouldBe(2);
            l.ToArray()[0].ShouldBe(1);
            l.ToArray()[1].ShouldBe(2);

            os.Persist();
            os = ObjectStore.Load(storage, true);
            l  = os.Resolve <CAppendOnlyList <int> >();

            l.ToArray().Length.ShouldBe(2);
            l.ToArray()[0].ShouldBe(1);
            l.ToArray()[1].ShouldBe(2);
        }
Exemplo n.º 3
0
 private WaitForOperator(int count, CAwaitable <IEnumerable <T> > awaitable, Stream <T> inner, bool completed, CAppendOnlyList <T> list)
 {
     _count     = count;
     Awaitable  = awaitable;
     _completed = completed;
     _inner     = inner;
     _list      = list;
 }
Exemplo n.º 4
0
            public WaitForOperator(int count, Stream <T> inner, TimeSpan?timeout, bool persistable)
            {
                _inner    = inner;
                _count    = count;
                Awaitable = new CAwaitable <IEnumerable <T> >(); //todo should the continuation be scheduled or not?
                _list     = new CAppendOnlyList <T>();

                if (timeout != null)
                {
                    Sleep.Until(timeout.Value, HandleTimeout, persistable);
                }

                _inner.Subscribe(this, Handle);
            }
Exemplo n.º 5
0
        public void SerializeAndDeserializeEmptyList()
        {
            var storage = new InMemoryStorageEngine();
            var os      = ObjectStore.New(storage);

            var l = new CAppendOnlyList <int>();

            l.ToArray().Length.ShouldBe(0);

            os.Entangle(l);
            os.Persist();

            os = ObjectStore.Load(storage, true);
            l  = os.Resolve <CAppendOnlyList <int> >();

            l.ToArray().Length.ShouldBe(0);
        }
Exemplo n.º 6
0
        public void SignalThrownException(Exception e)
        {
            if (Completed)
            {
                throw new InvalidOperationException("Completion or Exception has already been set for the awaitable");
            }

            _thrownException = Option.Some(e);

            foreach (var awaiter in _awaiters)
            {
                awaiter.SignalThrownException(e);
            }

            foreach (var awaiter in _ephemeralAwaiters)
            {
                awaiter.SignalCompletion();
            }

            _awaiters          = null;
            _ephemeralAwaiters = null;
        }
Exemplo n.º 7
0
        public void SignalCompletion()
        {
            if (Completed)
            {
                throw new InvalidOperationException("Completion or Exception has already been set for the awaitable");
            }

            IsSuccessfullyCompleted = true;

            foreach (var awaiter in _awaiters)
            {
                awaiter.SignalCompletion();
            }

            foreach (var awaiter in _ephemeralAwaiters)
            {
                awaiter.SignalCompletion();
            }

            _awaiters          = null;
            _ephemeralAwaiters = null;
        }
 private void SignalAwaitable()
 {
     _awaitable.SignalCompletion(_toDeliver);
     _awaitable = null;
     _toDeliver = new CAppendOnlyList <T>();
 }
Exemplo n.º 9
0
 private CAwaitable(CAppendOnlyList <NotYetCompletedAwaiter> awaiters, bool successfullyCompleted, Option <Exception> thrownException)
 {
     _awaiters               = awaiters;
     _thrownException        = thrownException;
     IsSuccessfullyCompleted = successfullyCompleted;
 }