Exemple #1
0
        private void OnTimeProcess(AwaiterItem item)
        {
            RPCPacket response = new RPCPacket();

            response.Status = (short)StatusCode.REQUEST_TIMEOUT;
            response.Data   = new object[] { $"Request {item.Request.Url} time out!" };
            Completed(item, response);
        }
Exemple #2
0
 public bool Completed(AwaiterItem item, RPCPacket data)
 {
     if (item.Completed(data))
     {
         item.Response = null;
         item.Request  = null;
         return(true);
     }
     return(false);
 }
Exemple #3
0
        public (int, TaskCompletionSource <Response>) Create(Request request, Type[] resultType, int timeout = 1000 * 100)
        {
            int  id = 0;
            long expiredTime;

            lock (this)
            {
                mID++;
                if (mID >= mEndID)
                {
                    mID = mStartID;
                }
                id = mID;
            }
            expiredTime = TimeWatch.GetElapsedMilliseconds() + timeout;
            var item = new AwaiterItem();

            item.ID         = id;
            item.ResultType = resultType;
            item.Request    = request;
            mAwaiterItemGroup.Set(item.ID, item);
            return(id, item.Create(expiredTime));
        }
Exemple #4
0
 public void Set(int id, AwaiterItem item)
 {
     mItems[id] = item;
 }
Exemple #5
0
 public void Set(int id, AwaiterItem item)
 {
     mGroups[id % Groups].Set(id, item);
 }