Skip to content
This repository has been archived by the owner on Feb 8, 2019. It is now read-only.

Commit

Permalink
some API fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Atsushi Eno committed Sep 18, 2012
1 parent 81926b9 commit aa1ef9a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public IDisposable SchedulePeriodic<TState> (TState state, TimeSpan period, Func
throw new NotImplementedException ();
}

public object GetService (Type serviceType)
protected override object GetService (Type serviceType)
{
throw new NotImplementedException ();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,26 @@ public override IDisposable ScheduleAbsolute<TState> (TState state, DateTimeOffs
ScheduledItemImpl<DateTimeOffset> t = null;
t = new ScheduledItemImpl<DateTimeOffset> (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<ScheduledItem<DateTimeOffset>> tasks, ScheduledItem<DateTimeOffset> 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);
}
}
}
28 changes: 2 additions & 26 deletions System.Reactive/System.Reactive.Concurrency/Scheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down Expand Up @@ -140,29 +139,6 @@ public static IDisposable Schedule<TState> (this IScheduler scheduler, TState st
return scheduler.Schedule<TState> (state, dueTime, f);
}

#if REACTIVE_2_0
// FIXME: shouldn't be public.
public
#else
internal
#endif
static void InternalAddTask (IList<ScheduledItem<DateTimeOffset>> tasks, ScheduledItem<DateTimeOffset> 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)
{
Expand Down

0 comments on commit aa1ef9a

Please sign in to comment.