Пример #1
0
        /// <summary>
        /// Create a new entry on the timer queue. Caller must not provide a time
        /// that has already been registered.
        /// </summary>
        /// <param name="uSecs">Time (absolute) expressed in usecs.</param>
        /// <param name="appContext">Ref to a context object supplied by the caller.</param>
        internal void RegisterTimer(long uSecTime, object appContext)
        {
            SoftTimerEntry ste = new SoftTimerEntry(uSecTime, appContext);

            lock (SoftTimerLock)
            {
                Debug.Assert(queue.ContainsKey(uSecTime) == false);
                queue.Add(uSecTime, ste);
            }
        }
Пример #2
0
        /// <summary>
        /// Returns the first expired entry on the list, if any.
        /// </summary>
        /// <returns>Returns the first expired entry on the list, if any.</returns>
        public SoftTimerEntry GetFirstExpired()
        {
            SoftTimerEntry ste = null;

            lock (SoftTimerLock)
            {
                // Find the first (lowest ordered) item on the queue.
                if (queue.Count > 0)
                {
                    ste = queue.First().Value;
                }

                if (ste != null && ste.USecTime <= TimeNowUSecs())
                {
                    queue.Remove(ste.USecTime);
                }
                else
                {
                    ste = null;
                }
            }

            return(ste);
        }
Пример #3
0
 /// <summary>
 /// Return an expired timer entry to the free pool.
 /// </summary>
 /// <param name="ste"></param>
 public void Free(SoftTimerEntry ste)
 {
     // no-op.
 }
Пример #4
0
 /// <summary>
 /// Return an expired timer entry to the free pool.
 /// </summary>
 /// <param name="ste"></param>
 public void Free(SoftTimerEntry ste)
 {
     // no-op.
 }
Пример #5
0
 /// <summary>
 /// Create a new entry on the timer queue. Caller must not provide a time
 /// that has already been registered.
 /// </summary>
 /// <param name="uSecs">Time (absolute) expressed in usecs.</param>
 /// <param name="appContext">Ref to a context object supplied by the caller.</param>
 internal void RegisterTimer(long uSecTime, object appContext)
 {
     SoftTimerEntry ste = new SoftTimerEntry(uSecTime, appContext);
     lock (SoftTimerLock)
     {
         Debug.Assert(queue.ContainsKey(uSecTime) == false);
         queue.Add(uSecTime, ste);
     }
 }