0

I am using the LMAX disruptor and it works really well.

I would like to execute some core affinity code (that needs to run ON THE DISRUPTOR HANDLER's THREAD), at the begginning of the disruptor's thread lifecycle.

I tried overriding the start method in the disruptor, but this code still runs on the executing thread and not the disruptor thread, something like this:

ThreadFactory factory = new ThreadFactoryBuilder().setNameFormat("DisruptorThread").build();
Disruptor<OrderBasedEventHolder> disruptor = new Disruptor<>(new Disruptor<Holder> disruptor = new Disruptor<Holder>(new HolderFactory(), (int) Math.pow(2, bufferExp), factory, pType, waitStrategy) {
        @Override public RingBuffer<OrderBasedEventHolder> start() {
            // Initialization code

            return super.start();
        }
    };
disruptor.start();

How can override the run() method of the thread created by the ThreadFactory?

Thanks!!!

1 Answers1

0

I have solved this before by enqueing an inital entry (with a special type) before any other entries and adding handling code for this initial "start" entry.

Slugart
  • 4,535
  • 24
  • 32