private List <VirtualSlot> RandomSlots() { List <int> iList = WaitingSlots; List <VirtualSlot> sList = new List <VirtualSlot>(); if (iList == null) { return(null); } while (iList.Count > 0) { int RandomID = iList[Common.Random.Next(0, iList.Count - 1)]; VirtualSlot vSlot = Slots.Item(RandomID); if (iList.Contains(RandomID)) { iList.Remove(RandomID); } if ((vSlot == null) || (vSlot.Status != SlotStatus.Downloading)) { continue; } sList.Add(vSlot); } return(sList); }
private int WorkLoad(int ServerID, List <int> vSlots) { int iLoad = 0; if (vSlots == null) { return(iLoad); } if (vSlots.Count == 0) { return(iLoad); } if (!StackExist(ServerID)) { return(iLoad); } foreach (int cID in vSlots) { VirtualSlot vSlot = Slots.Item(cID); if ((vSlot == null) || (vSlot.Status != SlotStatus.Downloading)) { continue; } IndexedCollection tStack = Stack(ServerID, vSlot.ID); if (tStack != null) { iLoad += tStack.Count; } } return(iLoad); }
private bool BestFit(World.Objects.Characters.Actions.SceneSkill ability, out VirtualSlot slot) { foreach (var s in _slots) { if (s.IsEmpty && s.Preference == ability.Type) { slot = s; return(true); } } slot = null; return(false); }
internal void Progress(long AddedBytes, VirtualConnection vConnection) { if (zSeg != null) { long rBytes = Interlocked.Read(ref AddedBytes); zSeg.Progress(rBytes); VirtualSlot vSlot = vConnection.Scheduler.Slots.Item(zSeg.SlotID); if (vSlot != null) { vSlot.Progress(rBytes); } } }
internal void Statistics(long AddedBytes, long RealTime, VirtualConnection vConnection) { if (zSeg != null) { long lTime = Interlocked.Read(ref RealTime); long rBytes = Interlocked.Read(ref AddedBytes); zSeg.Statistics(rBytes, lTime); VirtualSlot vSlot = vConnection.Scheduler.Slots.Item(zSeg.SlotID); if (vSlot != null) { vSlot.Statistics(rBytes, lTime); } } }