endian
endian

Reputation: 4294

Is it possible to use the Disruptor/Ringbuffer pattern without using a fixed-length array?

We have a Disruptor implementation that has a fixed-length array. Is it possible to implement a version of the pattern that does not rely on this array, but instead contains (possibly self-describing) lists of variable length objects. For example, a Ringbuffer of Protobuf objects?

I'm aware that the fixed-length array is for the "pre-allocation" step, but I consider it possible to approximate that step with one or more object pools.

Upvotes: 3

Views: 987

Answers (2)

Trevor Bernard
Trevor Bernard

Reputation: 992

It's definitely possible to implement a version of the disruptor that isn't backed by an Object array but it won't be high performance. A lot of thought and mechanical sympathy has gone into the design and implementation of the LMAX Exchange Disruptor.

Essentially the ring buffer is an pre-allocated object pool. From my experience, I've never had to worry about managing the ring buffer's resources directly in any real world code. The disruptor will automatically apply back pressure when necessary.

The library provides a nice DSL to construct a dependency graph for your application and basically gives you parallelism for free.

Upvotes: 1

James
James

Reputation: 9278

The ringbuffer in the java version of the disruptor is any array of references to objects. You can put whatever objects you want in there through the EventFactory instance you create.

Upvotes: 1

Related Questions