/// <summary> /// 向处理集群推送处理数据 /// </summary> /// <param name="pitem"></param> public void PushCluster(TaskID <TIn> pitem) { Init(); var min_saturation = MinCountTower();// 最小饱和 min_saturation.PushProcess(pitem); }
/// <summary> /// 向容器内推送任务数据,数据带有任务id /// </summary> /// <param name="task"></param> /// <returns></returns> public BaseDiverter <T> PushTask(TaskID <T> task) { // 无传入数据不处理 if (task == null) { return(this); } // 先检查分流容器是否空,空则创建 if (TaskDiverter == null) { TaskDiverter = new ConcurrentQueue <TaskID <T> >(); } // TaskDiverter.Enqueue(task); Interlocked.Increment(ref this.diverterCount); return(this); }
/// <summary> /// 向容器内推送任务数据 /// </summary> /// <param name="task"></param> /// <returns></returns> public BaseDiverter <T> PushTask(T task) { // 无传入数据不处理 if (task == null) { return(this); } // 先检查分流容器是否空,空则创建 if (TaskDiverter == null) { TaskDiverter = new ConcurrentQueue <TaskID <T> >(); } // 创建新任务 var new_task = new TaskID <T>() { TaskPID = 0, TaskData = task }; TaskDiverter.Enqueue(new_task); Interlocked.Increment(ref this.diverterCount); return(this); }
/// <summary> /// 输出分流具体处理 /// </summary> public override void Distribute() { Task.Run(() => { while (!stop) { if (this.DiverterCount <= 0) { loopDelay = 2000; } else { loopDelay = 20; } TaskID <TOut> out_data = PullTask(); if (out_data != null) { PullProcess(out_data); } Task.Delay(loopDelay); } }); }
/// <summary> /// 推送处理数据 /// </summary> /// <param name="task"></param> /// <returns></returns> public long PushProcess(TaskID <TIn> task) { Init(); InList.Enqueue(task); return(Add1Count()); }