com.lmax.disruptor
Class EventPublisher<E>

java.lang.Object
  extended by com.lmax.disruptor.EventPublisher<E>

public class EventPublisher<E>
extends java.lang.Object

Utility class for simplifying publication to the ring buffer.


Constructor Summary
EventPublisher(RingBuffer<E> ringBuffer)
          Construct from the ring buffer to be published to.
 
Method Summary
 void publishEvent(EventTranslator<E> translator)
          Publishes an event to the ring buffer.
 boolean tryPublishEvent(EventTranslator<E> translator, int capacity)
          Attempts to publish an event to the ring buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventPublisher

public EventPublisher(RingBuffer<E> ringBuffer)
Construct from the ring buffer to be published to.

Parameters:
ringBuffer - into which events will be published.
Method Detail

publishEvent

public void publishEvent(EventTranslator<E> translator)
Publishes an event to the ring buffer. It handles claiming the next sequence, getting the current (uninitialized) event from the ring buffer and publishing the claimed sequence after translation.

Parameters:
translator - The user specified translation for the event

tryPublishEvent

public boolean tryPublishEvent(EventTranslator<E> translator,
                               int capacity)
Attempts to publish an event to the ring buffer. It handles claiming the next sequence, getting the current (uninitialized) event from the ring buffer and publishing the claimed sequence after translation. Will return false if specified capacity was not available.

Parameters:
translator - The user specified translation for the event
capacity - The capacity that should be available before publishing
Returns:
true if the value was published, false if there was insufficient capacity.


Copyright © 2011 LMAX Ltd. All Rights Reserved.