Disruptor Java版和.NET版的区别
2014-02-20 14:04
381 查看
The main differences comes from the fact that .NET supports structs (value types), Java doesn't.
In Java, every entry (or message) exchanged by the disruptor needs to inherit from a base class called AbstractEntry. This class exposes the Sequence number required by the disruptor to process the messages, it is basically a header for the message.
In .NET we have replaced AbstractEntry by a generic struct: Entry<T>. An entry contains 2 fields: the sequence number and a field called data, used to store the message (of type T). Using this struct has several advantages:
the array in the RingBuffer is of type Entry<T>, when we need to access the Sequence number we don't have to dereference (Entry<T> is a struct so instances are directly nested in the array) and this improves cache spatial locality.
your message types do not need to implement or inherit from a base class, you can use POCOs.
最主要的区别是.NET支持结构类型(结构类型是值类型),而Java不支持。
在Java中,每一个被Disruptor交换的条目(或者消息)需要继承AbstractEntry基类。这个类提供了Disruptor处理消息时必须的序列号。它是消息头中最基本的信息。
在.NET中用泛型结构Entry<T>代替了Java中的AbstractEntry,一个条目包含两个域:一个是序列号,另一个是数据域,用来存储消息(T类型)。用结构有如下几个优点:
RingBuffer中的数组是Entry<T>类型,当我们需要访问序列号时,不需要解引用,并且能够提高缓存空间的局部性。
你的消息类型不需要实现或者继承基类,你可以使用POCOs.
In Java, every entry (or message) exchanged by the disruptor needs to inherit from a base class called AbstractEntry. This class exposes the Sequence number required by the disruptor to process the messages, it is basically a header for the message.
In .NET we have replaced AbstractEntry by a generic struct: Entry<T>. An entry contains 2 fields: the sequence number and a field called data, used to store the message (of type T). Using this struct has several advantages:
the array in the RingBuffer is of type Entry<T>, when we need to access the Sequence number we don't have to dereference (Entry<T> is a struct so instances are directly nested in the array) and this improves cache spatial locality.
your message types do not need to implement or inherit from a base class, you can use POCOs.
最主要的区别是.NET支持结构类型(结构类型是值类型),而Java不支持。
在Java中,每一个被Disruptor交换的条目(或者消息)需要继承AbstractEntry基类。这个类提供了Disruptor处理消息时必须的序列号。它是消息头中最基本的信息。
在.NET中用泛型结构Entry<T>代替了Java中的AbstractEntry,一个条目包含两个域:一个是序列号,另一个是数据域,用来存储消息(T类型)。用结构有如下几个优点:
RingBuffer中的数组是Entry<T>类型,当我们需要访问序列号时,不需要解引用,并且能够提高缓存空间的局部性。
你的消息类型不需要实现或者继承基类,你可以使用POCOs.
相关文章推荐
- 泛型-java与.NET中List<T>的区别
- 对于.NET和Java本质区别最精辟的评述
- 关于PHP、JAVA、.NET这三种技术的区别
- 培训过程中.NET教学与JAVA教学的区别-.NET篇
- Java 和 .Net 在异常处理机制上的区别
- SQL 与.net 的substring截取 与JAVA substring截取字符 用法 区别
- 对于.NET和Java本质区别最精辟的评述
- 菜鸟浅析JAVA,.NET,C/C++的区别
- Java 和 .Net 在异常处理机制上的区别
- .net和java区别
- java、php、.net关于web开发的区别
- 关于PHP、JAVA、.NET这三种技术的区别
- java枚举与.net中的枚举区别
- .NET与JAVA的本质区别
- 关于PHP、JAVA、.NET这三种技术的区别
- java枚举与.net中的枚举区别
- 关于PHP、JAVA、.NET这三种技术的区别
- PHP,.net,Java的区别
- .NET与JAVA的区别【完整版】
- 对于.NET和Java本质区别最精辟的评述