Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,7 @@ class Timer : IDisposable
//
// Note: the dictionary exists to "root" the timers so that they are not garbage collected and finalized while they are running.
//
#if !NO_HASHSET
private static readonly HashSet<System.Threading.Timer> s_timers = new HashSet<System.Threading.Timer>();
#else
private static readonly Dictionary<System.Threading.Timer, object> s_timers = new Dictionary<System.Threading.Timer, object>();
#endif

private Action<object> _action;
private System.Threading.Timer _timer;
Expand All @@ -270,12 +266,7 @@ public Timer(Action<object> action, object state, TimeSpan dueTime)
{
if (!_hasRemoved)
{
#if !NO_HASHSET
s_timers.Add(_timer);
#else
s_timers.Add(_timer, null);
#endif

_hasAdded = true;
}
}
Expand Down Expand Up @@ -323,11 +314,7 @@ class PeriodicTimer : IDisposable
//
// Note: the dictionary exists to "root" the timers so that they are not garbage collected and finalized while they are running.
//
#if !NO_HASHSET
private static readonly HashSet<System.Threading.Timer> s_timers = new HashSet<System.Threading.Timer>();
#else
private static readonly Dictionary<System.Threading.Timer, object> s_timers = new Dictionary<System.Threading.Timer, object>();
#endif

private Action _action;
private System.Threading.Timer _timer;
Expand All @@ -339,11 +326,7 @@ public PeriodicTimer(Action action, TimeSpan period)

lock (s_timers)
{
#if !NO_HASHSET
s_timers.Add(_timer);
#else
s_timers.Add(_timer, null);
#endif
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ public partial class LocalScheduler
/// Set of disposable handles to all of the current short term work Schedule calls,
/// allowing those to be cancelled upon a system clock change.
/// </summary>
#if !NO_HASHSET
private readonly HashSet<IDisposable> _shortTermWork = new HashSet<IDisposable>();
#else
private readonly Dictionary<IDisposable, object> _shortTermWork = new Dictionary<IDisposable, object>();
#endif

/// <summary>
/// Threshold where an item is considered to be short term work or gets moved from
Expand Down Expand Up @@ -191,11 +187,7 @@ private void ScheduleShortTermWork(WorkItem/*!*/ item)
// of WorkItem.Invoke.
//
var d = new SingleAssignmentDisposable();
#if !NO_HASHSET
_shortTermWork.Add(d);
#else
_shortTermWork.Add(d, null);
#endif

//
// We normalize the time delta again (possibly redundant), because we can't assume
Expand Down Expand Up @@ -386,12 +378,10 @@ internal void SystemClockChanged(object sender, SystemClockChangedEventArgs args
// is used to notice race conditions between cancellation and the timer firing (also
// guarded by the same gate object). See checks in ExecuteNextShortTermWorkItem.
//
#if !NO_HASHSET
foreach (var d in _shortTermWork)
#else
foreach (var d in _shortTermWork.Keys)
#endif
{
d.Dispose();
}

_shortTermWork.Clear();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,7 @@ abstract class Timer
//
// Note: the dictionary exists to "root" the timers so that they are not garbage collected and finalized while they are running.
//
#if !NO_HASHSET
protected static readonly HashSet<System.Threading.Timer> s_timers = new HashSet<System.Threading.Timer>();
#else
protected static readonly Dictionary<System.Threading.Timer, object> s_timers = new Dictionary<System.Threading.Timer, object>();
#endif
}

sealed class Timer<TState> : Timer, IDisposable
Expand Down Expand Up @@ -330,11 +326,7 @@ public Timer(IScheduler parent, TState state, TimeSpan dueTime, Func<IScheduler,
{
if (!_hasRemoved)
{
#if !NO_HASHSET
s_timers.Add(_timer);
#else
s_timers.Add(_timer, null);
#endif

_hasAdded = true;
}
Expand Down Expand Up @@ -393,11 +385,7 @@ abstract class PeriodicTimer
//
// Note: the dictionary exists to "root" the timers so that they are not garbage collected and finalized while they are running.
//
#if !NO_HASHSET
protected static readonly HashSet<System.Threading.Timer> s_timers = new HashSet<System.Threading.Timer>();
#else
protected static readonly Dictionary<System.Threading.Timer, object> s_timers = new Dictionary<System.Threading.Timer, object>();
#endif
}

sealed class PeriodicTimer<TState> : PeriodicTimer, IDisposable
Expand All @@ -418,11 +406,7 @@ public PeriodicTimer(TState state, TimeSpan period, Func<TState, TState> action)

lock (s_timers)
{
#if !NO_HASHSET
s_timers.Add(_timer);
#else
s_timers.Add(_timer, null);
#endif
}
}

Expand Down