private async Task LoadTasks() { var result = await apiService.GetAllTasks(); if (result.HttpResponse.IsSuccessStatusCode) { foreach (var item in result.Data) { switch (item.Status) { case 0: ToDo.Add(ViewModelHelper.Get(item)); break; case 1: Doing.Add(ViewModelHelper.Get(item)); break; case 2: Done.Add(ViewModelHelper.Get(item)); break; } } } }
public void RefreshMainWindow() { ToDo.Clear(); Doing.Clear(); Backlog.Clear(); Done.Clear(); var result = readDbDataToDisplay(); foreach (var i in result) { if (i.States == BackLog.State.IsToDo) { ToDo.Add(i); } else if (i.States == BackLog.State.IsDoing) { Doing.Add(i); } else if (i.States == BackLog.State.Backlog) { Backlog.Add(i); } else { Done.Add(i); } } }
public void Next() { if (Ready.Count == 0) { return; } var task = Ready[0]; task.Start = Point; ScheduleTask(task); Point = task.End; foreach (Link link in task.Outgoing) { link.Fulfilled = true; if (link.To.IncomingAllFulfilled) { link.To.Resource.Blocked.Remove(link.To); link.To.Resource.Ready.Add(link.To); } } Done.Add(task); Ready.Remove(task); }
/// <summary> /// Add the retrieved data to the datatable /// </summary> /// <param name="data"></param> /// <param name="request"></param> public void HandInAssignment(string data, TableMetadata request) { HandInAssignment_m.WaitOne(); Data[request] = data; Done.Add(request); HandInAssignment_m.ReleaseMutex(); }
/// <summary> /// Worker has finished a task, he push it to done in the TaskManager /// </summary> /// <param name="task"></param> public void SetDone(SymuTask task) { if (task is null) { throw new ArgumentNullException(nameof(task)); } if (!task.IsAssigned) { // Task has been cancelled return; } task.UnAssign(); var todo = ToDo.Contains(task); var inProgress = InProgress.Contains(task); if (todo) { ToDo.Remove(task); } else if (inProgress) { InProgress.Remove(task); } else { return; } task.SetDone(); if (_debug) { Done.Add(task); } // We don't want to track message as Task if (task.Parent is Message) { return; } if (todo) { TaskResult.ToDo--; } else { TaskResult.InProgress--; } TaskResult.Done++; TaskResult.WeightDone += task.Weight; TaskResult.Incorrectness += (int)task.Incorrectness; }
public void Track(ushort step, TasksManager manager) { if (manager == null) { throw new ArgumentNullException(nameof(manager)); } ToDo.Add(step, manager.ToDo.Count); InProgress.Add(step, manager.InProgress.Count); Done.Add(step, manager.Done.Count); Cancelled.Add(step, manager.Cancelled.Count); }
public virtual TSinkItem TryGetCreate(TSourceItem source) { var result = default(TSinkItem); if (!Dict.TryGetValue(source, out result)) { if (!(source is TSourceEdge)) { var sink = CreateItem(this.Source, this.Sink, source); if (ItemCreated != null) { ItemCreated(sink); } Sink.Add(sink); RegisterPair(source, sink); result = sink; } else { var sourceEdge = (TSourceEdge)source; var root = TryGetCreate(sourceEdge.Root); var leaf = TryGetCreate(sourceEdge.Leaf); Done.Add(sourceEdge.Root); Done.Add(sourceEdge.Leaf); if (!Dict.TryGetValue(source, out result)) { var sinkEdge = CreateEdge(this.Source, this.Sink, sourceEdge); sinkEdge.Root = root; sinkEdge.Leaf = leaf; if (ItemCreated != null) { ItemCreated(sinkEdge); } RegisterPair(sourceEdge, sinkEdge); Sink.Add(sinkEdge); EdgeCreated(sourceEdge, sinkEdge); result = sinkEdge; } } } return(result); }
/// <summary> /// Method that will refresh all the data in the view. Specifically it will add a backlog item to the new correct Observable list /// This is called from the edit Command, so we after deleted the item from the prvious view, add it to the new view. /// </summary> /// <param name="item">Specific item you want to change to a new listbox in the view</param> public void RefreshMainWindow(BackLog item) { if (item.States == BackLog.State.IsToDo) { ToDo.Add(item); } else if (item.States == BackLog.State.IsDoing) { Doing.Add(item); } else if (item.States == BackLog.State.Backlog) { Backlog.Add(item); } else { Done.Add(item); } }
private void SplitTask() { Debug.WriteLine($"Number of items in Task: {Task.Count}"); foreach (var task in Task) { switch (task.Progress) { case Progress.ToDo: ToDo.Add(task); break; case Progress.Doing: Doing.Add(task); break; case Progress.Done: Done.Add(task); break; default: break; } } }
private void Plan(RegisterClass @class) { int i; var clobbered = Map.ClobberedRegs.Get(@class); var willAlloc = _willAlloc.Get(@class); var willFree = clobbered & ~willAlloc; var list = VaList[(int)@class]; var count = Count.Get(@class); var state = VariableContext.State; // Calculate 'willAlloc' and 'willFree' masks based on mandatory masks. for (i = 0; i < count; i++) { var va = list[i]; var vd = va.VariableData; var vaFlags = va.Flags; var regIndex = vd.RegisterIndex; var regMask = regIndex != RegisterIndex.Invalid ? Utils.Mask(regIndex) : 0; if (vaFlags.IsSet(VariableFlags.RReg)) { // Planning register allocation. First check whether the variable is // already allocated in register and if it can stay there. Function // arguments are passed either in a specific register or in stack so // we care mostly of mandatory registers. var inRegs = va.InRegs; if (inRegs == 0) { inRegs = va.AllocableRegs; } // Optimize situation where the variable has to be allocated in a // mandatory register, but it's already allocated in register that // is not clobbered (i.e. it will survive function call). if ((regMask & inRegs) != 0 || ((regMask & ~clobbered) != 0 && !vaFlags.IsSet(VariableFlags.Unuse))) { va.InRegIndex = regIndex; va.Flags |= VariableFlags.AllocRDone; Done.Add(@class); } else { willFree |= regMask; } } else { // Memory access - if variable is allocated it has to be freed. if (regMask != 0) { willFree |= regMask; } else { va.Flags |= VariableFlags.AllocRDone; Done.Add(@class); } } } // Occupied registers without 'willFree' registers; contains basically // all the registers we can use to allocate variables without inRegs // speficied. var occupied = state.Occupied.Get(@class) & ~willFree; var willSpill = 0; // Find the best registers for variables that are not allocated yet. Only // useful for Gp registers used as call operand. for (i = 0; i < count; i++) { var va = list[i]; var vd = va.VariableData; var vaFlags = va.Flags; if (vaFlags.IsSet(VariableFlags.AllocRDone) || !vaFlags.IsSet(VariableFlags.RReg)) { continue; } // All registers except Gp used by call itself must have inRegIndex. var m = va.InRegs; if (@class != RegisterClass.Gp || m != 0) { if (!(m != 0)) { throw new ArgumentException(); } va.InRegIndex = m.FindFirstBit(); willSpill |= occupied & m; continue; } m = va.AllocableRegs & ~(willAlloc ^ m); m = GuessAlloc(@class, vd, m); if (!(m != 0)) { throw new ArgumentException(); } var candidateRegs = m & ~occupied; if (candidateRegs == 0) { candidateRegs = m & occupied & ~state.Modified.Get(@class); if (candidateRegs == 0) { candidateRegs = m; } } if (!vaFlags.IsSet(VariableFlags.WReg) && !vaFlags.IsSet(VariableFlags.Unuse) && candidateRegs.IsSet(~clobbered)) { candidateRegs &= ~clobbered; } var regIndex = candidateRegs.FindFirstBit(); var regMask = Utils.Mask(regIndex); va.InRegIndex = regIndex; va.InRegs = regMask; willAlloc |= regMask; willSpill |= regMask & occupied; willFree &= ~regMask; occupied |= regMask; } // Set calculated masks back to the allocator; needed by spill() and alloc(). _willSpill.Set(@class, willSpill); _willAlloc.Set(@class, willAlloc); }
private void Alloc(RegisterClass @class) { if (Done.Get(@class) == Count.Get(@class)) { return; } var list = VaList[(int)@class]; var count = Count.Get(@class); var state = VariableContext.State; // var sVars = state.GetListByClass(@class); bool didWork; do { didWork = false; int i; for (i = 0; i < count; i++) { var aVa = list[i]; var aVd = aVa.VariableData; if ((aVa.Flags & (VariableFlags.RReg | VariableFlags.AllocRDone)) != VariableFlags.RReg) { continue; } var aIndex = aVd.RegisterIndex; var bIndex = aVa.InRegIndex; // Shouldn't be the same. if (aIndex == bIndex) { throw new ArgumentException(); } var bVd = state.GetListByClass(@class)[bIndex]; if (bVd != null) { var bVa = bVd.Attributes; // Gp registers only - Swap two registers if we can solve two // allocation tasks by a single 'xchg' instruction, swapping // two registers required by the instruction/node or one register // required with another non-required. if (@class != RegisterClass.Gp) { continue; } Translator.SwapGp(aVd, bVd); aVa.Flags |= VariableFlags.AllocRDone; Done.Add(@class); // Doublehit, two registers allocated by a single swap. if (bVa != null && bVa.InRegIndex == aIndex) { bVa.Flags |= VariableFlags.AllocRDone; Done.Add(@class); } didWork = true; } else if (aIndex != RegisterIndex.Invalid) { Translator.Move(aVd, @class, bIndex); VariableContext.ClobberedRegs.Or(@class, Utils.Mask(bIndex)); aVa.Flags |= VariableFlags.AllocRDone; Done.Add(@class); didWork = true; } else { Translator.Alloc(aVd, @class, bIndex); VariableContext.ClobberedRegs.Or(@class, Utils.Mask(bIndex)); aVa.Flags |= VariableFlags.AllocRDone; Done.Add(@class); didWork = true; } } }while (didWork); }
private void Plan(RegisterClass @class) { if (Done.Get(@class) == Count.Get(@class)) { return; } int i; int willAlloc = _willAlloc.Get(@class); int willFree = 0; var list = VaList[(int)@class]; var count = Count.Get(@class); var state = VariableContext.State; // Calculate 'willAlloc' and 'willFree' masks based on mandatory masks. for (i = 0; i < count; i++) { var va = list[i]; var vd = va.VariableData; var vaFlags = va.Flags; var regIndex = vd.RegisterIndex; var regMask = (regIndex != RegisterIndex.Invalid) ? Utils.Mask(regIndex) : 0; if ((vaFlags & VariableFlags.XReg) != 0) { // Planning register allocation. First check whether the variable is // already allocated in register and if it can stay allocated there. // // The following conditions may happen: // // a) Allocated register is one of the mandatoryRegs. // b) Allocated register is one of the allocableRegs. var mandatoryRegs = va.InRegs; var allocableRegs = va.AllocableRegs; if (regMask != 0) { // Special path for planning output-only registers. if ((vaFlags & VariableFlags.XReg) == VariableFlags.WReg) { var outRegIndex = va.OutRegIndex; mandatoryRegs = (outRegIndex != RegisterIndex.Invalid) ? Utils.Mask(outRegIndex) : 0; if ((mandatoryRegs | allocableRegs).IsSet(regMask)) { va.OutRegIndex = regIndex; va.Flags |= VariableFlags.AllocWDone; if (mandatoryRegs.IsSet(regMask)) { // Case 'a' - 'willAlloc' contains initially all inRegs from all VarAttr's. if (!((willAlloc & regMask) != 0)) { throw new ArgumentException(); } } else { // Case 'b'. va.OutRegIndex = regIndex; willAlloc |= regMask; } Done.Add(@class); continue; } } else { if ((mandatoryRegs | allocableRegs).IsSet(regMask)) { va.InRegIndex = regIndex; va.Flags |= VariableFlags.AllocRDone; if (mandatoryRegs.IsSet(regMask)) { // Case 'a' - 'willAlloc' contains initially all inRegs from all VarAttr's. if (!((willAlloc & regMask) != 0)) { throw new ArgumentException(); } } else { // Case 'b'. va.InRegs |= regMask; willAlloc |= regMask; } Done.Add(@class); continue; } } } // Variable is not allocated or allocated in register that doesn't // match inRegs or allocableRegs. The next step is to pick the best // register for this variable. If `inRegs` contains any register the // decision is simple - we have to follow, in other case will use // the advantage of `guessAlloc()` to find a register (or registers) // by looking ahead. But the best way to find a good register is not // here since now we have no information about the registers that // will be freed. So instead of finding register here, we just mark // the current register (if variable is allocated) as `willFree` so // the planner can use this information in the second step to plan the // allocation as a whole. willFree |= regMask; } else { // Memory access - if variable is allocated it has to be freed. if (regMask != 0) { willFree |= regMask; } else { va.Flags |= VariableFlags.AllocRDone; Done.Add(@class); } } } // Occupied registers without 'willFree' registers; contains basically // all the registers we can use to allocate variables without inRegs // speficied. var occupied = state.Occupied.Get(@class) & ~willFree; var willSpill = 0; // Find the best registers for variables that are not allocated yet. for (i = 0; i < count; i++) { var va = list[i]; var vd = va.VariableData; var vaFlags = va.Flags; if ((vaFlags & VariableFlags.XReg) != 0) { if ((vaFlags & VariableFlags.XReg) == VariableFlags.WReg) { if (vaFlags.IsSet(VariableFlags.AllocWDone)) { continue; } // Skip all registers that have assigned outRegIndex. Spill if occupied. if (va.OutRegIndex != RegisterIndex.Invalid) { var outRegs = Utils.Mask(va.OutRegIndex); willSpill |= occupied & outRegs; continue; } } else { if (vaFlags.IsSet(VariableFlags.AllocRDone)) { continue; } // We skip all registers that have assigned inRegIndex, indicates that // the register to allocate in is known. if (va.InRegIndex != RegisterIndex.Invalid) { var inRegs = va.InRegs; willSpill |= occupied & inRegs; continue; } } var m = va.InRegs; if (va.OutRegIndex != RegisterIndex.Invalid) { m |= Utils.Mask(va.OutRegIndex); } m = va.AllocableRegs & ~(willAlloc ^ m); m = GuessAlloc(vd, m, @class); if (!(m != 0)) { throw new ArgumentException(); } var candidateRegs = m & ~occupied; var homeMask = vd.HomeMask; if (candidateRegs == 0) { candidateRegs = m & occupied & ~state.Modified.Get(@class); if (candidateRegs == 0) { candidateRegs = m; } } // printf("CANDIDATE: %s %08X\n", vd->getName(), homeMask); if (candidateRegs.IsSet(homeMask)) { candidateRegs &= homeMask; } var regIndex = candidateRegs.FindFirstBit(); var regMask = Utils.Mask(regIndex); if ((vaFlags & VariableFlags.XReg) == VariableFlags.WReg) { va.OutRegIndex = regIndex; } else { va.InRegIndex = regIndex; va.InRegs = regMask; } willAlloc |= regMask; willSpill |= regMask & occupied; willFree &= ~regMask; occupied |= regMask; } else if ((vaFlags & VariableFlags.XMem) != 0) { var regIndex = vd.RegisterIndex; if (regIndex != RegisterIndex.Invalid && (vaFlags & VariableFlags.XMem) != VariableFlags.WMem) { willSpill |= Utils.Mask(regIndex); } } } _willSpill.Set(@class, willSpill); _willAlloc.Set(@class, willAlloc); }