Exemplo n.º 1
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));
        }
Exemplo n.º 2
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));
        }