public void Enqueue(StagedTask stagedTask) { var entry = new TaskEntry(stagedTask, ++_sequence); if (_first == null) { _first = entry; _last = entry; _count = 1; } else { _last.Next = entry; _last = entry; _count++; } // re-initialize already completed queues for (var stage = 0; stage <= _maxStage; stage++) { if (_orderedStage[stage] && _byOrderedStageLast[stage] == null) { _byOrderedStageLast[stage] = entry; } } SetEntryCorrelation(entry, stagedTask.InitialCorrelationId); EnqueueForStage(entry, 0); }
public void EnqueueTask(StagedTask workItem, CheckpointTag workItemCheckpointTag) { if (_queueState == QueueState.Stopped) throw new InvalidOperationException("Queue is Stopped"); ValidateQueueingOrder(workItemCheckpointTag); _queuePendingEvents.Enqueue(workItem); }
public void EnqueueTask(StagedTask workItem, CheckpointTag workItemCheckpointTag) { if (_queueState == QueueState.Stopped) { throw new InvalidOperationException("Queue is Stopped"); } ValidateQueueingOrder(workItemCheckpointTag); _queuePendingEvents.Enqueue(workItem); }
private StagedTask ProcessOneTask(StagedTask runThisOnly) { while (_tasks.Count > 0 && _tasks.Peek().Completed) { _tasks.Dequeue(); } _precedingCorrelations.Clear(); var previousTaskMinimumProcessingStage = int.MaxValue; var taskStage = int.MaxValue; foreach (var entry in _tasks) { previousTaskMinimumProcessingStage = Math.Min(taskStage, previousTaskMinimumProcessingStage); taskStage = entry.ReadForStage; if (_precedingCorrelations.Contains(entry.Task.CorrelationId)) { break; } _precedingCorrelations.Add(entry.Task.CorrelationId); if (entry.Busy) { continue; } if (entry.Completed) { continue; } if (_orderedStage[taskStage] && taskStage > previousTaskMinimumProcessingStage) { continue; } if (runThisOnly != null && entry.Task != runThisOnly) // skip other tasks (this is to allow current entry continue to the next step - required by TickHandling) { break; // do not skip, we can process only in this order } // here we should be at the first StagedTask of current processing level which is not busy entry.Busy = true; entry.Task.Process(taskStage, readyForStage => CompleteTaskProcessing(entry, readyForStage)); return(entry.Task); } return(null); }
public int Process() { int processed = 0; StagedTask taskProcessed = null; while (_tasks.Count > 0) { taskProcessed = ProcessOneTask(taskProcessed); if (taskProcessed == null) { break; } processed++; } return(processed); }
public void Enqueue(StagedTask stagedTask) { var entry = new TaskEntry(stagedTask, ++_sequence); if (_first == null) { _first = entry; _last = entry; _count = 1; } else { _last.Next = entry; _last = entry; _count++; } // re-initialize already completed queues for (var stage = 0; stage <= _maxStage; stage++) if (_orderedStage[stage] && _byOrderedStageLast[stage] == null) _byOrderedStageLast[stage] = entry; SetEntryCorrelation(entry, stagedTask.InitialCorrelationId); EnqueueForStage(entry, 0); }
public TaskEntry(StagedTask task, long sequence) { Task = task; ReadForStage = -1; Sequence = sequence; }
private StagedTask ProcessOneTask(StagedTask runThisOnly) { while (_tasks.Count > 0 && _tasks.Peek().Completed) _tasks.Dequeue(); _precedingCorrelations.Clear(); var previousTaskMinimumProcessingStage = int.MaxValue; var taskStage = int.MaxValue; foreach (var entry in _tasks) { previousTaskMinimumProcessingStage = Math.Min(taskStage, previousTaskMinimumProcessingStage); taskStage = entry.ReadForStage; if (_precedingCorrelations.Contains(entry.Task.CorrelationId)) break; _precedingCorrelations.Add(entry.Task.CorrelationId); if (entry.Busy) continue; if (entry.Completed) continue; if (_orderedStage[taskStage] && taskStage > previousTaskMinimumProcessingStage) continue; if (runThisOnly != null && entry.Task != runThisOnly) // skip other tasks (this is to allow current entry continue to the next step - required by TickHandling) break; // do not skip, we can process only in this order // here we should be at the first StagedTask of current processing level which is not busy entry.Busy = true; entry.Task.Process(taskStage, readyForStage => CompleteTaskProcessing(entry, readyForStage)); return entry.Task; } return null; }
public void Enqueue(StagedTask stagedTask) { _tasks.Enqueue(new TaskEntry(stagedTask)); }
public TaskEntry(StagedTask task) { Task = task; }
public TaskEntry(StagedTask task) { Task = task; BusyCorrelationId = task.InitialCorrelationId; }