Пример #1
0
 public void Add(T tuple)
 {
     if (WaitingActions.First != null && WaitingAction <T> .Take(this, tuple))
     {
         return;
     }
     _written.Add(tuple);
 }
Пример #2
0
        public void Abort()
        {
            Debug.Assert(_parent != null);
            WaitingAction.RemoveAll(WaitingActions);

            for (var i = 0; i < _taken.Count; i++)
            {
                _taken[i].Abort();
            }

            Cleanup();
        }
Пример #3
0
        public void Commit()
        {
            Debug.Assert(_parent != null);
            WaitingAction.RemoveAll(WaitingActions);

            int count;
            var written = _written.GetArray(out count);

            _parent.AddRange(written, count);

            Cleanup();
        }
Пример #4
0
        public IDisposable Read(IQuery <T> query, Action <T> callback, LinkedList <IWaitingAction> ownerList)
        {
            var readItem = TryRead(query);

            if (readItem != null)
            {
                callback(readItem);
                return(DisposableEx.Null());
            }

            // add waiting action
            return(WaitingAction <T> .Install(this, Root != null?Root.WaitingActions : ownerList, query, callback, false));
        }
Пример #5
0
        public IDisposable Take(IQuery <T> query, Action <T> callback, LinkedList <IWaitingAction> ownerList)
        {
            var takenItem = TryTake(query);

            if (takenItem != null)
            {
                callback(takenItem);
                return(DisposableEx.Null());
            }

            // add waiting action
            return(WaitingAction <T> .Install(this, Root != null?Root.WaitingActions : ownerList, query, callback, true));
        }
Пример #6
0
 private void AddRange(T[] tuples, int count)
 {
     if (count == 0)
     {
         return;
     }
     if (WaitingActions.First == null)
     {
         _written.AddRange(tuples, count);
     }
     else
     {
         _written.AddRange(tuples, count - (WaitingAction <T> .Take(this, tuples, count)));
     }
 }
Пример #7
0
 public void Dispose()
 {
     WaitingAction.RemoveAll(_globalWaitingActions);
     if (_transactionCount == 0)
     {
         return;
     }
     // Just rollback topmost transactions internally
     for (var i = 0; i < _transactionTablesCount; i++)
     {
         _transactionTables[i].Table.AbortToRoot();
     }
     Array.Clear(_transactionTables, 0, _transactionTablesCount);
     _transactionTablesCount = 0;
     _transactionCount       = 0;
 }
Пример #8
0
        public void AbortToRoot()
        {
            Debug.Assert(_parent != null);
            WaitingAction.RemoveAll(WaitingActions);

            for (var i = 0; i < _taken.Count; i++)
            {
                _taken[i].AbortToRoot();
            }

            if (_parent.HierarchyLevel != 0)
            {
                _parent.AbortToRoot();
            }

            Cleanup();
        }
Пример #9
0
 public WaitingActionDisposable(WaitingAction <T> action)
 {
     _action = action;
 }