1 // 2 // Copyright (c) 2010-2018 Antmicro 3 // 4 // This file is licensed under the MIT License. 5 // Full license text is available in 'licenses/MIT.txt'. 6 // 7 using System; 8 9 namespace Antmicro.Renode.Time 10 { 11 /// <summary> 12 /// Represents an object generating time flow. 13 /// </summary> 14 public interface ITimeSource 15 { 16 /// <summary> 17 /// Gets or sets a virtual time unit of synchronization of this time source. 18 /// </summary> 19 /// <remark> 20 /// All time handles obtained from this object are guaranteed not to be de-synchronized by more than the current <see cref="Quantum">. 21 /// Setting small values increases execution precision but can degrade performance. 22 /// The value of this property can be safely changed in any moment, but the new value won't be in use before the next synchronization phase. 23 /// </remark> 24 TimeInterval Quantum { get; set; } 25 26 /// <summary> 27 /// Gets time domain of this time source. 28 /// </summary> 29 ITimeDomain Domain { get; } 30 31 /// <summary> 32 /// Gets moment of the nearest synchronization point. 33 /// </summary> 34 TimeInterval NearestSyncPoint { get; } 35 36 /// <summary> 37 /// Gets the amount of virtual time elapsed from the perspective of this time source. 38 /// </summary> 39 TimeInterval ElapsedVirtualTime { get; } 40 41 /// <summary> 42 /// Registers a new time sink in this source. 43 /// </summary> 44 /// <remarks> 45 /// All sinks registered in the same source are synchronized and guaranteed not to be de-synchronized by more than the current <see cref="Quantum">. 46 /// </remarks> RegisterSink(ITimeSink sink)47 void RegisterSink(ITimeSink sink); 48 49 /// <summary> 50 /// Used by a time sink to inform that it became active again. 51 /// </summary> ReportHandleActive()52 void ReportHandleActive(); 53 54 /// <summary> 55 /// Used by a time sink to inform that it has processed some part of the granted time. 56 /// </summary> 57 /// <remark> 58 /// Calling this method does not mean that the granted time is fully processed. It is just used to update Elapsed Virtual Time more often than Quantum in order to handle timers well. 59 /// </remark> ReportTimeProgress()60 void ReportTimeProgress(); 61 } 62 } 63