How should one use Disruptor (Disruptor Pattern) to build real-world message systems?

前端 未结 3 1913
迷失自我
迷失自我 2020-12-12 16:03

As the RingBuffer up-front allocates objects of a given type, how can you use a single ring buffer to process messages of various different types?

You can\'t create

3条回答
  •  不思量自难忘°
    2020-12-12 16:26

    There is a library called Javolution (http://javolution.org/) that let's you defined objects as structs with fixed-length fields like string[40] etc. that rely on byte-buffers internally instead of variable size objects... that allows the token ring to be initialized with fixed size objects and thus (hopefully) contiguous blocks of memory that allow the cache to work more efficiently.

    We are using that for passing events / messages and use standard strings etc. for our business-logic.

提交回复
热议问题