コード例 #1
0
        private WorkerQueue <T> PickupQueue(string queueID)
        {
            WorkerQueue <T> workerQueue = null;

            try
            {
                if (!this._queues.ContainsKey(queueID))
                {
                    DebugUtil.Log("WorkerQueueGroup: >>> Try to acquire queue locker.");
                    lock (this._queuelocker)
                    {
                        DebugUtil.Log("WorkerQueueGroup: Get queue locker.");
                        if (!this._queues.ContainsKey(queueID))
                        {
                            workerQueue        = new WorkerQueue <T>(this._batchSize, this._flushInterval, queueID);
                            workerQueue.Flush += new Action <object, List <T> >(this.OnInnerQueueFlush);
                            this._queues.Add(queueID, workerQueue);
                        }
                    }
                    DebugUtil.Log("WorkerQueueGroup: <<< Release queue locker.");
                }
                workerQueue = this._queues[queueID];
            }
            catch (Exception exception)
            {
                DebugUtil.LogException(exception);
            }
            return(workerQueue);
        }
コード例 #2
0
 public void Enqueue(string queueID, IList <T> items)
 {
     ParamterUtil.CheckEmptyString("queueID", queueID);
     ParamterUtil.CheckNull("items", items);
     try
     {
         if (items.Count > 0)
         {
             WorkerQueue <T> workerQueue = this.PickupQueue(queueID);
             if (workerQueue == null)
             {
                 DebugUtil.Log(string.Format("WorkerQueueGroup: failed to pick up queue with id '{0}'.", queueID));
             }
             else
             {
                 foreach (T item in items)
                 {
                     workerQueue.Enqueue(item);
                 }
             }
         }
     }
     catch (Exception exception)
     {
         DebugUtil.LogException(exception);
     }
 }
コード例 #3
0
 private void OnInnerQueueFlush(object queueObj, List <T> items)
 {
     try
     {
         if (this.Flush != null)
         {
             WorkerQueue <T> workerQueue = queueObj as WorkerQueue <T>;
             if (workerQueue != null)
             {
                 this.Flush(workerQueue, items);
             }
         }
     }
     catch (Exception exception)
     {
         DebugUtil.LogException(exception);
     }
 }