public override AsyncRequestElement PushAndOptionalPop(AsyncRequestElement req)
        {
            AsyncRequestElement popped = null;
            uint lowestRunningOrder    = uint.MaxValue;
            int  lowestRunningIdx      = -1;
            uint lowestCompletedOrder  = uint.MaxValue;
            int  lowestCompletedIdx    = -1;

            for (int i = 0; i < q.Length; i++)
            {
                popped = q[i];
                if (popped == null)
                {
                    q[i] = req.Start(order++);
                    return(null);
                }
                if (popped.IsCompleted)
                {
                    if (popped.queuedOrder >= lowestCompletedOrder)
                    {
                        continue;
                    }
                    lowestCompletedIdx = i;
                    continue;
                }
                if (popped.queuedOrder >= lowestRunningOrder)
                {
                    continue;
                }
                lowestRunningIdx = i;
            }

            //Pop and replace still running item
            int popIdx = lowestCompletedIdx;

            if (popIdx < 0)
            {
                popIdx = lowestRunningIdx;
            }
            popped    = q[popIdx];
            q[popIdx] = null;

            try
            {
                popped.EndInvoke();
            }
            finally
            {
                if (req != null)
                {
                    q[popIdx] = req.Start(order++);
                }
            }
            return(popped);
        }
Пример #2
0
        private void asyncAdd(AsyncRequestElement ctx)
        {
            JObject accu = ctx.Context as JObject;

            if (accu != null)
            {
                Connection.Post(DocType.GetUrlForAdd(accu), accu, _recordSerializer).ThrowIfError();
                return;
            }
            flushCache((List <ESBulkEntry>)ctx.Context);
        }
        public override AsyncRequestElement Pop()
        {
            var popped = q;

            q = null;
            if (popped != null)
            {
                popped.EndInvoke();
            }
            return(popped);
        }
        public override List <AsyncRequestElement> PopAll()
        {
            var popped = q;

            q = null;
            if (popped == null)
            {
                return(EMPTY);
            }
            popped.EndInvoke();
            return(new List <AsyncRequestElement>(1)
            {
                popped
            });
        }
        public override AsyncRequestElement Pop()
        {
            AsyncRequestElement popped = null;
            uint lowestRunningOrder    = uint.MaxValue;
            int  lowestRunningIdx      = -1;
            uint lowestCompletedOrder  = uint.MaxValue;
            int  lowestCompletedIdx    = -1;

            for (int i = 0; i < q.Length; i++)
            {
                popped = q[i];
                if (popped == null)
                {
                    continue;
                }
                if (popped.IsCompleted)
                {
                    if (popped.queuedOrder >= lowestCompletedOrder)
                    {
                        continue;
                    }
                    lowestCompletedIdx = i;
                    continue;
                }
                if (popped.queuedOrder >= lowestRunningOrder)
                {
                    continue;
                }
                lowestRunningIdx = i;
            }
            int popIdx = lowestCompletedIdx;

            if (lowestCompletedIdx >= 0)
            {
                goto POP;
            }
            popIdx = lowestRunningIdx;
            if (popIdx < 0)
            {
                return(null);
            }

POP:
            popped    = q[popIdx];
            q[popIdx] = null;
            popped.EndInvoke();
            return(popped);
        }
Пример #6
0
        private void asyncAdd(AsyncRequestElement ctx)
        {
            List <JObject> list = ctx.Context as List <JObject>;

            if (list != null)
            {
                foreach (var obj in list)
                {
                    if (!mapper.OptWrite(accumulator, maxNullIndex))
                    {
                        //Just passthrough to the next endpoint if this record had a failing hash-value
                        PassThrough(null, accumulator); //PW Kan dit? null als ctx?
                    }
                }
            }
        }
        public override List <AsyncRequestElement> PopAll()
        {
            List <AsyncRequestElement> ret = null;

            for (int i = 0; i < q.Length; i++)
            {
                AsyncRequestElement popped = q[i];
                if (popped == null)
                {
                    continue;
                }
                q[i] = null;
                if (ret == null)
                {
                    ret = new List <AsyncRequestElement>();
                }
                popped.EndInvoke();
                ret.Add(popped);
            }
            return(ret == null ? EMPTY : ret);
        }
        public override AsyncRequestElement PushAndOptionalPop(AsyncRequestElement req)
        {
            AsyncRequestElement popped = q;

            q = null;
            //dumpQ("before");
            try
            {
                if (popped != null)
                {
                    popped.EndInvoke();
                }
            }
            finally
            {
                if (req != null)
                {
                    q = req.Start(0);
                }
            }
            //dumpQ("after");
            return(popped);
        }
 public override AsyncRequestElement PushAndOptionalPop(AsyncRequestElement req)
 {
     req.Run();
     return(req);
 }
 /// <summary>
 /// If a request is added, it takes the place of an empty or ready request.
 /// If not found, the request takes the place of the oldest request in the Q, but before that, a wait is issued on the request to be removed.
 /// Adding an element to the Q implies calling BeginInvoke on the element that is added
 /// The removed item is returned (or null if there was nothing to remove)
 /// </summary>
 public abstract AsyncRequestElement PushAndOptionalPop(AsyncRequestElement req);
Пример #11
0
        private void getEnum(AsyncRequestElement ctx)
        {
            int i = (int)ctx.Context;

            ctx.Result = mapper.GetObjectEnumerator(i, true);
        }
Пример #12
0
 public void LoadUrl(AsyncRequestElement elt)
 {
     loadUrl(this.StreamElt.FullName);
 }