47

This page on MSDN states that

If you do not use the overload which takes a scheduler as an argument, Rx will pick a default scheduler by using the principle of least concurrency. This means that the scheduler which introduces the least amount of concurrency that satisfies the needs of the operator is chosen. For example, for operators returning an observable with a finite and small number of messages, Rx calls Immediate. For operators returning a potentially large or infinite number of messages, CurrentThread is called. For operators which use timers, ThreadPool is used.

I would like to actually have a reference sheet for which observable operators use which default Scheduler, but I can't find one anywhere. What are the default Schedulers for each observable operator?

Alex
  • 7,639
  • 3
  • 45
  • 58
  • 1
    I'm actually surprised there isn't a list somewhere...if I get some time to dump into it, I'll walk through the rx codebase and see if I can compile a list, but no, I'm not aware of any floating 'round the nets... – JerKimball Mar 13 '13 at 16:50
  • Yeah I hunted around too, to no avail. Some of them are obvious but some really aren't! – Alex Mar 13 '13 at 17:34

1 Answers1

77

Wow, that was not trivial to find...

Deep within the bowels of the System.Reactive.Concurrency namespace, there is an internal static class called SchedulerDefaults, which is declared as:

internal static class SchedulerDefaults
{
    internal static IScheduler AsyncConversions 
    { get { return DefaultScheduler.Instance; }}

    internal static IScheduler ConstantTimeOperations 
    { get { return ImmediateScheduler.Instance; }}

    internal static IScheduler Iteration 
    { get { return CurrentThreadScheduler.Instance; }}

    internal static IScheduler TailRecursion 
    { get { return ImmediateScheduler.Instance; }}

    internal static IScheduler TimeBasedOperations 
    { get { return DefaultScheduler.Instance; }}
}

AsyncConversions is used by:

Start, ToAsync, FromAsyncPattern

ConstantTimeOperations is used by:

Empty, GetSchedulerForCurrentContext, Return, StartWith, Throw

Iteration is used by:

Generate, Range, Repeat, TakeLast, ToObservable, and the ReplaySubject<T>

TailRecursion is used by:

Run

TimeBasedOperations is used by:

Buffer, Delay, DelaySubscription, Generate, Interval, Sample, Skip, SkipLast
SkipUntil, Take, TakeLast, TakeLastBuffer, TakeUntil, Throttle, TimeInterval,
Timeout, Timer, Timestamp, Window
Alex
  • 7,639
  • 3
  • 45
  • 58
JerKimball
  • 16,584
  • 3
  • 43
  • 55