public void Schedule(Element element, ulong time) { Console.WriteLine("SliceCollection:Schedule {0}", TimePrec.DecodeTime(time)); var slice = (ulong)(time >> TimePrec.TimePrecisionBits); var fraction = (ulong)(time & TimePrec.TimePrecisionMask); if (slice < EngineSettings.MaxTimeslices) { // first fraction if (slice == 0) { _fractionCache.EnsureCache(fraction); } // roll timeslice for index slice += _currentSlice; if (slice >= EngineSettings.MaxTimeslices) { slice -= EngineSettings.MaxTimeslices; } _slices[slice].Fractions.Schedule(element, fraction); } else { _hibernates.Hibernate(element, time); } }
public void Hibernate(Element element, ulong time) { Console.WriteLine("HibernateCollection:Hibernate {0}", TimePrec.DecodeTime(time)); var hibernate = _hibernates[0]; hibernate.Elements.Add(element, time); }
public void Add(Element element, ulong time) { Console.WriteLine("ElementCollection:Add {0}", TimePrec.DecodeTime(time)); var metadata = BitConverter.GetBytes(time); switch (element.ScheduleStyle) { case ElementScheduleStyle.FirstWins: _singles.MergeFirstWins(element, metadata); break; case ElementScheduleStyle.LastWins: _singles.MergeLastWins(element, metadata); break; case ElementScheduleStyle.Multiple: var elementRef = new ElementRef { Element = element, Metadata = metadata }; _multiples.AddFirst(elementRef); break; default: Console.WriteLine("Warn:UNDEFINED"); throw new NotImplementedException(); } }
internal void Schedule(Element element, ulong fraction) { Console.WriteLine("SliceFractionCollection:Schedule {0}", TimePrec.DecodeTime(fraction)); SliceFraction fractionAsObject; if (!TryGetValue(fraction, out fractionAsObject)) { fractionAsObject.xtor(); Add(fraction, fractionAsObject); } fractionAsObject.Elements.Add(element, 0); }
public bool EvaluateFrame(ulong frameTime, Action <SliceFraction> evaluateNode) { Console.WriteLine("SliceCollection:EvaluateFrame {0}", TimePrec.DecodeTime(frameTime)); bool firstLoop = true; _fractionCache.BeginFrame(); long timeRemaining = (long)frameTime; while (timeRemaining <= 0) { if (!_fractionCache.BeginSlice(_slices[_currentSlice])) { // no fractions available, advance a wholeTime timeRemaining -= (long)TimePrec.TimeScaler; } else { // first-time time adjust if (firstLoop) { firstLoop = false; //time += (long)_fractionCache.CurrentFraction; } long elapsedTime; if (!EvaluateSlice(timeRemaining, out elapsedTime, evaluateNode)) { // slice not completely evaluated, continue with same slice next frame _fractionCache.EndFrame(); return(false); } // advance an elapsedTime timeRemaining -= elapsedTime; } _fractionCache.EndSlice(); // advance a slice MoveNextSlice(); } _fractionCache.EndFrame(); return(true); }
public void EvaluateFrameBegin(ulong frameTime) { Console.WriteLine("SliceCollection:EvaluateFrameBegin {0}", TimePrec.DecodeTime(frameTime)); }