Rx 2:线程安全 [英] Rx 2: Thread Safe

查看:61
本文介绍了Rx 2:线程安全的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

RX 2主题和操作符是否成为线程安全?


我正在寻找像Switch这样的运算符的反汇编,我注意到它们确实在实现中使用了锁。 / p>


       
public void OnNext(TSource值)



        {



         
lock this ._ parent._gate)



          {



           
if ((
this ._ parent._latest!=( long
this ._ id)



             
返回 ;



           
._ parent._observer.OnNext(value);



         }


       }



RX主题和运算符的哪一部分是线程安全的,哪些不是?


Bart你能给我们任何官方评论吗?


Bnaya Eshet

解决方案

答案很长,所以我开始写一篇关于这个主题的博客文章。请继续关注!


Does RX 2 subjects and operator become thread safe?

I was looking on disassembly of operators like Switch and I have notice that they do use lock within the implementation.

        public void OnNext(TSource value)

        {

          lock (this._parent._gate)

          {

            if ((long) this._parent._latest != (long) this._id)

              return;

            this._parent._observer.OnNext(value);

          }

        }

What part of RX subject and operators are thread-safe and which aren’t?

Bart can you give us any official comment?


Bnaya Eshet

解决方案

The answer is quite lengthy, so I've started to write a blog post about this topic. Stay tuned!


这篇关于Rx 2:线程安全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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