Exemplo n.º 1
0
        public int Compare(StableConnectionElement <TApi> x, StableConnectionElement <TApi> y)
        {
            if (object.ReferenceEquals(x, null) && object.ReferenceEquals(y, null))
            {
                return(0);
            }

            if (object.ReferenceEquals(x, null))
            {
                return(-1);
            }

            if (object.ReferenceEquals(y, null))
            {
                return(1);
            }

            if (!x.CanBeUsedForCommunication && !y.CanBeUsedForCommunication)
            {
                return(y.ConcurrentRequestCount.CompareTo(x.ConcurrentRequestCount));
            }

            if (!x.CanBeUsedForCommunication)
            {
                return(-1);
            }

            if (!y.CanBeUsedForCommunication)
            {
                return(1);
            }

            return(y.ConcurrentRequestCount.CompareTo(x.ConcurrentRequestCount));
        }
Exemplo n.º 2
0
        protected override void DestroyElement(StableConnectionElement <TApi> elem)
        {
            if (elem == null)
            {
                return;
            }

            elem.Dispose();
        }
Exemplo n.º 3
0
        public static int CompareItems(StableConnectionElement <TApi> x, StableConnectionElement <TApi> y, out bool stopHere)
        {
            if (object.ReferenceEquals(x, null) && object.ReferenceEquals(y, null))
            {
                stopHere = false;
                return(0);
            }

            if (object.ReferenceEquals(x, null))
            {
                stopHere = y.CanBeUsedForCommunication && y.ConcurrentRequestCount == 0;
                return(-1);
            }

            if (object.ReferenceEquals(y, null))
            {
                stopHere = x.CanBeUsedForCommunication && x.ConcurrentRequestCount == 0;
                return(1);
            }

            if (!x.CanBeUsedForCommunication && !y.CanBeUsedForCommunication)
            {
                stopHere = false;
                return(y.ConcurrentRequestCount.CompareTo(x.ConcurrentRequestCount));
            }

            if (!x.CanBeUsedForCommunication)
            {
                stopHere = y.ConcurrentRequestCount == 0;
                return(-1);
            }

            if (!y.CanBeUsedForCommunication)
            {
                stopHere = x.ConcurrentRequestCount == 0;
                return(1);
            }

            if (y.ConcurrentRequestCount > x.ConcurrentRequestCount)
            {
                stopHere = x.ConcurrentRequestCount == 0;
                return(1);
            }

            if (y.ConcurrentRequestCount < x.ConcurrentRequestCount)
            {
                stopHere = y.ConcurrentRequestCount == 0;
                return(-1);
            }

            stopHere = x.ConcurrentRequestCount == 0;
            return(0);
        }
Exemplo n.º 4
0
        public static int CompareItems(StableConnectionElement <TApi> x, StableConnectionElement <TApi> y)
        {
            bool tmp = false;

            return(CompareItems(x, y, out tmp));
        }
Exemplo n.º 5
0
 protected override bool IsBetterAllocateNew(StableConnectionElement <TApi> elem)
 {
     return(elem == null || !elem.CanBeUsedForCommunication);
 }
Exemplo n.º 6
0
 protected override int CompareElements(StableConnectionElement <TApi> a, StableConnectionElement <TApi> b, out bool stopHere)
 {
     return(StableConnectionElementComparer <TApi> .CompareItems(a, b, out stopHere));
 }
Exemplo n.º 7
0
 protected override bool IsValidElement(StableConnectionElement <TApi> elem)
 {
     return(elem != null);
 }
Exemplo n.º 8
0
 protected override bool CreateElement(out StableConnectionElement <TApi> elem, int timeout,
                                       CancellationToken token)
 {
     elem = new StableConnectionElement <TApi>(_factory, _maxAsyncQueryCount, _isSyncOpen);
     return(true);
 }