Esempio 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));
        }
Esempio n. 2
0
        protected override void DestroyElement(StableConnectionElement <TApi> elem)
        {
            if (elem == null)
            {
                return;
            }

            elem.Dispose();
        }
Esempio 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);
        }
Esempio n. 4
0
        public static int CompareItems(StableConnectionElement <TApi> x, StableConnectionElement <TApi> y)
        {
            bool tmp = false;

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