什么是每个经营者观察到的默认调度? [英] What are the default Schedulers for each observable operator?

查看:175
本文介绍了什么是每个经营者观察到的默认调度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MSDN上指出。


如果你不使用它使用一个调度程序作为参数过载,接收将使用最小的并发的原则选择默认的调度。这意味着被选择它引入并发量最少满足操作者的需要的调度。例如,对于操作员返回一个可观察到的具有有限和小数目的消息,接收呼叫立即。对于运营商返回一个潜在的大或无限数量的邮件,CurrentThread被调用。对于使用定时器,线程池使用的运营商。




我想实际上有一个参考片而观察到的运营商使用其默认的调度,但我不能找到一个任何地方。 什么是每个观察到的运营商默认的调度程序?


解决方案

哇,这是不平凡的发现...



深的 System.Reactive.Concurrency 命名空间的肠子内,有一个内部的静态类名为 SchedulerDefaults ,它被声明为:

 静态内部类SchedulerDefaults 
{
内部静态IScheduler AsyncConversions
{{返回DefaultScheduler.Instance; }}
内部静态IScheduler ConstantTimeOperations
{{返回ImmediateScheduler.Instance; }}
内部静态IScheduler迭代
{{返回CurrentThreadScheduler.Instance; }}
内部静态IScheduler TailRecursion
{{返回ImmediateScheduler.Instance; }}
内部静态IScheduler TimeBasedOperations
{{返回DefaultScheduler.Instance; }}
}



AsyncConversions 使用方式:

 开始,ToAsync,FromAsyncPattern 

ConstantTimeOperations 所使用的:

 清空,GetSchedulerForCurrentContext,返回,StartWith,扔

迭代被使用:

 生成,范围,重复,TakeLast,ToObservable和ReplaySubject< T> 



TailRecursion 所使用的:

 运行

TimeBasedOperations 所使用的:

 缓冲,延时,DelaySubscription,生成,间隔,采样,跳过,SkipLast 
SkipUntil,拿,TakeLast,TakeLastBuffer,TakeUntil,油门,TimeInterval所,
超时,定时,时间戳,窗口


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?

解决方案

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

这篇关于什么是每个经营者观察到的默认调度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆