concurrent programming using the...

101
Concurrent Programming Using The Disruptor Trisha Gee, Developer at LMAX @trisha_gee mechanitis.blogspot.com Thursday, 24 May 12

Upload: others

Post on 12-Jul-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Concurrent Programming Using The Disruptor

Trisha Gee, Developer at LMAX@trisha_gee

mechanitis.blogspot.com

Thursday, 24 May 12

Page 2: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

The Disruptor?

Thursday, 24 May 12

Page 3: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

What I’m covering

• Overview of the Disruptor

• Create your own!

• Turn it up to Eleven

• Q&A

Thursday, 24 May 12

Page 4: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

What is it?

• Data structure and work flow with no contention.

• Very fast message passing.

• Allows you to go truly parallel.

Thursday, 24 May 12

Page 5: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

So...?

Thursday, 24 May 12

Page 6: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

The Magic RingBuffer

Thursday, 24 May 12

Page 7: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

The Magic RingBuffer

Thursday, 24 May 12

Page 8: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

The Magic RingBuffer

Thursday, 24 May 12

Page 9: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

The Magic RingBuffer

Thursday, 24 May 12

Page 10: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

The Magic RingBuffer

Thursday, 24 May 12

Page 11: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

The Magic RingBuffer

Thursday, 24 May 12

Page 12: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

The Magic RingBuffer

Thursday, 24 May 12

Page 13: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Creating a RingBuffer

final RingBuffer<SimpleEvent> ringBuffer = new RingBuffer<SimpleEvent>(SimpleEvent.EVENT_FACTORY, RING_BUFFER_SIZE);

Thursday, 24 May 12

Page 14: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

The Events are Buckets

Thursday, 24 May 12

Page 15: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Great! I want one!

public class SimpleEvent { public static final EventFactory<SimpleEvent> EVENT_FACTORY = new SimpleEventFactory();

private volatile String value;

private static class SimpleEventFactory implements EventFactory<SimpleEvent> { @Override public SimpleEvent newInstance() { return new SimpleEvent(); } } }

Thursday, 24 May 12

Page 16: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

I’ve got a RingBuffer!

• Erm.... how do I poke things into it?

Thursday, 24 May 12

Page 17: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

The Publisher

Thursday, 24 May 12

Page 18: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 19: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 20: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 21: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 22: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 23: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 24: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

What do I do?

SimpleEventTranslator translator = new SimpleEventTranslator();

EventPublisher<SimpleEvent> publisher = new EventPublisher<SimpleEvent>(ringBuffer);

// poke your translator here// ...and when you’re done...publisher.publishEvent(translator);

public class SimpleEventTranslator implements EventTranslator<SimpleEvent>

Thursday, 24 May 12

Page 25: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

...so now I want to read

• The Disruptor provides nice batching behaviour for free

Thursday, 24 May 12

Page 26: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

BatchEventProcessor

Thursday, 24 May 12

Page 27: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 28: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 29: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 30: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 31: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 32: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 33: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 34: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 35: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 36: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 37: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 38: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 39: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 40: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 41: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

...and all you need is...

public class SimpleEventHandler implements EventHandler<SimpleEvent> { @Override public void onEvent(final SimpleEvent event, final long sequence, final boolean endOfBatch) throws Exception { // do stuff } }

Thursday, 24 May 12

Page 42: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Shiny. So what?

Thursday, 24 May 12

Page 43: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Let’s go parallel

Thursday, 24 May 12

Page 44: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

And now for something different...

Thursday, 24 May 12

Page 45: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Remember Henry Ford?

Thursday, 24 May 12

Page 46: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 47: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 48: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 49: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 50: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 51: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 52: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 53: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Complex workflow...

Thursday, 24 May 12

Page 54: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

What on Earth has this got to do with RingBuffers?!

Thursday, 24 May 12

Page 55: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 56: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 57: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 58: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 59: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 60: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 61: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 62: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 63: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 64: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 65: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 66: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 67: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 68: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 69: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 70: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 71: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 72: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 73: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 74: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 75: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 76: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 77: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 78: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 79: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 80: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 81: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 82: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 83: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 84: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 85: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 86: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 87: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 88: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 89: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 90: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 91: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Thursday, 24 May 12

Page 92: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Don’t wrap the buffer!

ringBuffer.setGatingSequences(finalEventProcessor.getSequence());

Thursday, 24 May 12

Page 93: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Caveats

Thursday, 24 May 12

Page 94: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Is that it?

• Wait and claim strategies

• Batch publishing

• Multiple publishers

• Different EventHandlers

• The Wizard

• You don’t even need a RingBuffer...

Thursday, 24 May 12

Page 95: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

You get...

• A framework the encourages you to model your domain

• The ability to run in parallel but single-threaded

• Nice, simple Java

• Reliable ordering

• ...and it can be very fast

Thursday, 24 May 12

Page 96: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

More Information

• Google Code Site, including Wikihttp://code.google.com/p/disruptor/

• Blogs, e.g. mine: mechanitis.blogspot.com

• Presentations

• Google Group

Thursday, 24 May 12

Page 97: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

Q&A

Thursday, 24 May 12

Page 98: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

WorkerPool

Thursday, 24 May 12

Page 99: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

AggregateEventHandler

Thursday, 24 May 12

Page 100: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

WaitStrategies

• BlockingWaitStrategy

• BusySpinWaitStrategy

• SleepingWaitStrategy

• YieldingWaitStrategy

Thursday, 24 May 12

Page 101: Concurrent Programming Using The Disruptorgotocon.com/.../TrishaGee_ConcurrentProgrammingUsingTheDisrupt… · Concurrent Programming Using The Disruptor Trisha Gee, Developer at

ClaimStrategies

• SingleThreadedClaimStrategy

• MultiThreadedClaimStrategy

• MultiThreadedLowContentionClaimStrategy

Thursday, 24 May 12