diff --git a/System.Reactive.Core/System.Reactive.Concurrency/DefaultScheduler.cs b/System.Reactive.Core/System.Reactive.Concurrency/DefaultScheduler.cs index c411936..4a51439 100644 --- a/System.Reactive.Core/System.Reactive.Concurrency/DefaultScheduler.cs +++ b/System.Reactive.Core/System.Reactive.Concurrency/DefaultScheduler.cs @@ -30,7 +30,7 @@ public IDisposable SchedulePeriodic (TState state, TimeSpan period, Func throw new NotImplementedException (); } - public object GetService (Type serviceType) + protected override object GetService (Type serviceType) { throw new NotImplementedException (); } diff --git a/System.Reactive.Core/System.Reactive.Concurrency/LocalScheduler.cs b/System.Reactive.Core/System.Reactive.Concurrency/LocalScheduler.cs index 8b2b372..a658814 100644 --- a/System.Reactive.Core/System.Reactive.Concurrency/LocalScheduler.cs +++ b/System.Reactive.Core/System.Reactive.Concurrency/LocalScheduler.cs @@ -67,7 +67,7 @@ object IServiceProvider.GetService (Type serviceType) return GetService (serviceType); } - protected object GetService (Type serviceType) + protected virtual object GetService (Type serviceType) { if (serviceType == typeof (INotifySystemClockChanged)) return timer_clock_monitor; diff --git a/System.Reactive/System.Reactive.Concurrency/HistoricalScheduler.cs b/System.Reactive/System.Reactive.Concurrency/HistoricalScheduler.cs index 439cb12..27eb75f 100644 --- a/System.Reactive/System.Reactive.Concurrency/HistoricalScheduler.cs +++ b/System.Reactive/System.Reactive.Concurrency/HistoricalScheduler.cs @@ -40,9 +40,26 @@ public override IDisposable ScheduleAbsolute (TState state, DateTimeOffs ScheduledItemImpl t = null; t = new ScheduledItemImpl (dueTime, () => { tasks.Remove (t); return action (this, state); }); - Scheduler.InternalAddTask (tasks, t); + InternalAddTask (tasks, t); return new CompositeDisposable (Disposable.Create (() => tasks.Remove (t)), t); } + + internal static void InternalAddTask (IList> tasks, ScheduledItem task) + { + // It is most likely appended in order, so don't use ineffective List.Sort(). Simple comparison makes it faster. + // Also, it is important that events are processed *in order* when they are scheduled at the same moment. + int pos = -1; + DateTimeOffset dueTime = task.DueTime; + for (int i = tasks.Count - 1; i >= 0; i--) { + if (dueTime >= tasks [i].DueTime) { + tasks.Insert (i + 1, task); + pos = i; + break; + } + } + if (pos < 0) + tasks.Insert (0, task); + } } } diff --git a/System.Reactive/System.Reactive.Concurrency/Scheduler.cs b/System.Reactive/System.Reactive.Concurrency/Scheduler.cs index 4e347bc..616709a 100644 --- a/System.Reactive/System.Reactive.Concurrency/Scheduler.cs +++ b/System.Reactive/System.Reactive.Concurrency/Scheduler.cs @@ -23,9 +23,8 @@ public static ImmediateScheduler Immediate { } #if REACTIVE_2_0 - // FIXME: find out correct return type and instance - public static IScheduler Default { - get { return NewThread; } + public static DefaultScheduler Default { + get { return DefaultScheduler.Instance; } } // Those properties are [Obsolete] only in non-portable build... @@ -140,29 +139,6 @@ public static IDisposable Schedule (this IScheduler scheduler, TState st return scheduler.Schedule (state, dueTime, f); } -#if REACTIVE_2_0 - // FIXME: shouldn't be public. - public -#else - internal -#endif - static void InternalAddTask (IList> tasks, ScheduledItem task) - { - // It is most likely appended in order, so don't use ineffective List.Sort(). Simple comparison makes it faster. - // Also, it is important that events are processed *in order* when they are scheduled at the same moment. - int pos = -1; - DateTimeOffset dueTime = task.DueTime; - for (int i = tasks.Count - 1; i >= 0; i--) { - if (dueTime >= tasks [i].DueTime) { - tasks.Insert (i + 1, task); - pos = i; - break; - } - } - if (pos < 0) - tasks.Insert (0, task); - } - #if REACTIVE_2_0 public static ISchedulerLongRunning AsLongRunning (this IScheduler scheduler) {