Concurrent Programming
                          Using The Disruptor
                            Trisha Gee, Developer at LMAX
                                       @trisha_gee
                                   mechanitis.blogspot.com




Tuesday, 9 October 12
The Disruptor?




Tuesday, 9 October 12
What is it?

                  • Data structure and work flow with no
                        contention.
                  • Very fast message passing.
                  • Allows you to go truly parallel.


Tuesday, 9 October 12
The Magic RingBuffer




Tuesday, 9 October 12
The Magic RingBuffer




Tuesday, 9 October 12
The Magic RingBuffer




Tuesday, 9 October 12
The Magic RingBuffer




Tuesday, 9 October 12
The Magic RingBuffer




Tuesday, 9 October 12
The Magic RingBuffer




Tuesday, 9 October 12
The Magic RingBuffer




Tuesday, 9 October 12
The Events are Buckets




Tuesday, 9 October 12
I’ve got a RingBuffer!


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



Tuesday, 9 October 12
The Publisher




Tuesday, 9 October 12
Tuesday, 9 October 12
Tuesday, 9 October 12
Tuesday, 9 October 12
Tuesday, 9 October 12
Tuesday, 9 October 12
Tuesday, 9 October 12
...so now I want to read


                    • The Disruptor provides nice batching
                        behaviour for free




Tuesday, 9 October 12
BatchEventProcessor




Tuesday, 9 October 12
Tuesday, 9 October 12
Tuesday, 9 October 12
Tuesday, 9 October 12
Tuesday, 9 October 12
Tuesday, 9 October 12
Tuesday, 9 October 12
Tuesday, 9 October 12
Tuesday, 9 October 12
Tuesday, 9 October 12
Tuesday, 9 October 12
Tuesday, 9 October 12
Tuesday, 9 October 12
Tuesday, 9 October 12
Tuesday, 9 October 12
Shiny. So what?



Tuesday, 9 October 12
Complex Workflows




Tuesday, 9 October 12
...and in the Disruptor?




Tuesday, 9 October 12
Let’s go parallel




Tuesday, 9 October 12
Caveats

                    • Your ring buffer needs to be bigger than 12
                    • Event handlers are on separate threads
                    • Mileage May Vary - always performance test


Tuesday, 9 October 12
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
Tuesday, 9 October 12
Is that it?

                    • Wait strategies
                    • Batch publishing
                    • Multiple publishers
                    • The Wizard
                    • You don’t even need a RingBuffer...

Tuesday, 9 October 12
More Information

                    • Github:
                        github.com/LMAX-Exchange/disruptor
                    • Google Group
                    • Blogs


Tuesday, 9 October 12
Q&A



Tuesday, 9 October 12
WorkerPool




Tuesday, 9 October 12
AggregateEventHandler




Tuesday, 9 October 12
WaitStrategies

                    • BlockingWaitStrategy
                    • BusySpinWaitStrategy
                    • SleepingWaitStrategy
                    • YieldingWaitStrategy

Tuesday, 9 October 12
ClaimStrategies

                    • SingleThreadedClaimStrategy
                    • MultiThreadedClaimStrategy
                    • MultiThreadedLowContentionClaimStrategy


Tuesday, 9 October 12

Introduction to the Disruptor