/// <summary> /// copies an instance of <see cref="SafeSystemSchedule"/> /// </summary> /// <param name="copy">the schedule to copy</param> public SafeSystemSchedule(SafeSystemSchedule copy) { if (copy == null) { throw new ArgumentNullException(nameof(copy)); } //copy int values _count = copy._count; _next = copy._next; _top = copy._top; _start = copy._start; _end = copy._end; _rrStart = copy._rrStart; _rrEnd = copy._rrEnd; _laneCount = copy._laneCount; //initialize int arrays _lanes = new SystemInfo[_laneCount]; _running = new bool[_laneCount]; //copy values in lane arrays for (int i = 0; i < _laneCount; i++) { _lanes[i] = copy._lanes[i]; _running[i] = copy._running[i]; } //copy storage arrays _systemCache = new PagedArray <SystemInfo>(copy._entries.PagePower, copy._entries.PageCount); _entries = new PagedArray <Entry>(copy._entries.PagePower, copy._entries.PageCount); for (int i = 0; i < _top; i++) { _systemCache[i] = copy._systemCache[i]; _entries[i] = copy._entries[i]; } //copy run recurrences for (int i = 0; i < copy._runRecurrences.Count; i++) { _runRecurrences.Add(copy._runRecurrences[i]); } //copy free space queue for (int i = 0; i < copy.freeSpace.Count; i++) { int space = copy.freeSpace.Dequeue(); freeSpace.Enqueue(space); copy.freeSpace.Enqueue(space); } }
///<inheritdoc/> public ISystemSchedule CreateSchedule(SystemType type, int lanes) { if (type == SystemType.Logic) { SafeSystemSchedule schedule = new SafeSystemSchedule(type, lanes); schedule.AddFromRegistry(this); return(schedule); } else { SystemSchedule schedule = new SystemSchedule(type, lanes, (int)((GetTypeCount(type)) + 1)); schedule.AddFromRegistry(this); return(schedule); } }