private <A, B, C> void translateAndPublishBatch(final EventTranslatorThreeArg<E, A, B, C> translator, final A[] arg0, final B[] arg1, final C[] arg2, int batchStartsAt, final int batchSize, final long finalSequence) { final long initialSequence = finalSequence - (batchSize - 1); try { long sequence = initialSequence; final int batchEndsAt = batchStartsAt + batchSize; for (int i = batchStartsAt; i < batchEndsAt; i++) { translator.translateTo(get(sequence), sequence++, arg0[i], arg1[i], arg2[i]); } } finally { sequencer.publish(initialSequence, finalSequence); } }
/** * Allows three user supplied arguments * * @see #publishEvent(EventTranslator) * @param translator The user specified translation for the event * @param arg0 A user supplied argument. * @param arg1 A user supplied argument. * @param arg2 A user supplied argument. * @return true if the value was published, false if there was insufficient * capacity. */ public <A, B, C> boolean tryPublishEvent(EventTranslatorThreeArg<E, A, B, C> translator, A arg0, B arg1, C arg2) { try { final long sequence = sequencer.tryNext(); translateAndPublish(translator, sequence, arg0, arg1, arg2); return true; } catch (InsufficientCapacityException e) { return false; } }
/** * Allows three user supplied arguments per event. * * @param translator The user specified translation for the event * @param batchStartsAt The first element of the array which is within the batch. * @param batchSize The actual size of the batch. * @param arg0 An array of user supplied arguments, one element per event. * @param arg1 An array of user supplied arguments, one element per event. * @param arg2 An array of user supplied arguments, one element per event. * @return true if the value was published, false if there was insufficient * capacity. * @see #publishEvents(EventTranslator[]) */ public <A, B, C> boolean tryPublishEvents(EventTranslatorThreeArg<E, A, B, C> translator, int batchStartsAt, int batchSize, A[] arg0, B[] arg1, C[] arg2) { checkBounds(arg0, arg1, arg2, batchStartsAt, batchSize); try { final long finalSequence = sequencer.tryNext(batchSize); translateAndPublishBatch(translator, arg0, arg1, arg2, batchStartsAt, batchSize, finalSequence); return true; } catch (InsufficientCapacityException e) { return false; } }
private <A, B, C> void translateAndPublish(EventTranslatorThreeArg<E, A, B, C> translator, long sequence, A arg0, B arg1, C arg2) { try { translator.translateTo(get(sequence), sequence, arg0, arg1, arg2); } finally { sequencer.publish(sequence); } }
@Override public <A, B, C> void publishEvent(EventTranslatorThreeArg<ResponseEvent, A, B, C> translator, A arg0, B arg1, C arg2) { throw new UnsupportedOperationException(); }
@Override public <A, B, C> boolean tryPublishEvent(EventTranslatorThreeArg<ResponseEvent, A, B, C> translator, A arg0, B arg1, C arg2) { throw new UnsupportedOperationException(); }
@Override public <A, B, C> void publishEvents(EventTranslatorThreeArg<ResponseEvent, A, B, C> translator, A[] arg0, B[] arg1, C[] arg2) { throw new UnsupportedOperationException(); }
@Override public <A, B, C> void publishEvents(EventTranslatorThreeArg<ResponseEvent, A, B, C> translator, int batchStartsAt, int batchSize, A[] arg0, B[] arg1, C[] arg2) { throw new UnsupportedOperationException(); }
@Override public <A, B, C> boolean tryPublishEvents(EventTranslatorThreeArg<ResponseEvent, A, B, C> translator, A[] arg0, B[] arg1, C[] arg2) { throw new UnsupportedOperationException(); }
@Override public <A, B, C> boolean tryPublishEvents(EventTranslatorThreeArg<ResponseEvent, A, B, C> translator, int batchStartsAt, int batchSize, A[] arg0, B[] arg1, C[] arg2) { throw new UnsupportedOperationException(); }
/** * Allows three user supplied arguments per event. * * @param translator The user specified translation for the event * @param batchStartsAt The first element of the array which is within the batch. * @param batchSize The number of elements in the batch. * @param arg0 An array of user supplied arguments, one element per event. * @param arg1 An array of user supplied arguments, one element per event. * @param arg2 An array of user supplied arguments, one element per event. * @see #publishEvents(EventTranslator[]) */ public <A, B, C> void publishEvents(EventTranslatorThreeArg<E, A, B, C> translator, int batchStartsAt, int batchSize, A[] arg0, B[] arg1, C[] arg2) { checkBounds(arg0, arg1, arg2, batchStartsAt, batchSize); final long finalSequence = sequencer.next(batchSize); translateAndPublishBatch(translator, arg0, arg1, arg2, batchStartsAt, batchSize, finalSequence); }
/** * Allows three user supplied arguments * * @see #publishEvent(EventTranslator) * @param translator The user specified translation for the event * @param arg0 A user supplied argument. * @param arg1 A user supplied argument. * @param arg2 A user supplied argument. * @return true if the value was published, false if there was insufficient capacity. */ public <A, B, C> boolean tryPublishEvent(EventTranslatorThreeArg<E, A, B, C> translator, A arg0, B arg1, C arg2) { try { final long sequence = sequencer.tryNext(); translateAndPublish(translator, sequence, arg0, arg1, arg2); return true; } catch (InsufficientCapacityException e) { return false; } }
/** * Allows three user supplied arguments per event. * * @param translator The user specified translation for the event * @param batchStartsAt The first element of the array which is within the batch. * @param batchSize The actual size of the batch. * @param arg0 An array of user supplied arguments, one element per event. * @param arg1 An array of user supplied arguments, one element per event. * @param arg2 An array of user supplied arguments, one element per event. * @return true if the value was published, false if there was insufficient capacity. * @see #publishEvents(EventTranslator[]) */ public <A, B, C> boolean tryPublishEvents(EventTranslatorThreeArg<E, A, B, C> translator, int batchStartsAt, int batchSize, A[] arg0, B[] arg1, C[] arg2) { checkBounds(arg0, arg1, arg2, batchStartsAt, batchSize); try { final long finalSequence = sequencer.tryNext(batchSize); translateAndPublishBatch(translator, arg0, arg1, arg2, batchStartsAt, batchSize, finalSequence); return true; } catch (InsufficientCapacityException e) { return false; } }
/** * Allows three user supplied arguments * * @see #publishEvent(EventTranslator) * @param translator The user specified translation for the event * @param arg0 A user supplied argument. * @param arg1 A user supplied argument. * @param arg2 A user supplied argument. */ public <A, B, C> void publishEvent(EventTranslatorThreeArg<E, A, B, C> translator, A arg0, B arg1, C arg2) { final long sequence = sequencer.next(); translateAndPublish(translator, sequence, arg0, arg1, arg2); }
/** * Allows three user supplied arguments per event. * * @param translator The user specified translation for the event * @param arg0 An array of user supplied arguments, one element per event. * @param arg1 An array of user supplied arguments, one element per event. * @param arg2 An array of user supplied arguments, one element per event. * @see #publishEvents(com.lmax.disruptor.EventTranslator[]) */ public <A, B, C> void publishEvents(EventTranslatorThreeArg<E, A, B, C> translator, A[] arg0, B[] arg1, C[] arg2) { publishEvents(translator, 0, arg0.length, arg0, arg1, arg2); }
/** * Allows three user supplied arguments per event. * * @param translator The user specified translation for the event * @param arg0 An array of user supplied arguments, one element per event. * @param arg1 An array of user supplied arguments, one element per event. * @param arg2 An array of user supplied arguments, one element per event. * @return true if the value was published, false if there was insufficient * capacity. * @see #publishEvents(com.lmax.disruptor.EventTranslator[]) */ public <A, B, C> boolean tryPublishEvents(EventTranslatorThreeArg<E, A, B, C> translator, A[] arg0, B[] arg1, C[] arg2) { return tryPublishEvents(translator, 0, arg0.length, arg0, arg1, arg2); }
/** * Allows three user supplied arguments per event. * * @param translator The user specified translation for the event * @param arg0 An array of user supplied arguments, one element per event. * @param arg1 An array of user supplied arguments, one element per event. * @param arg2 An array of user supplied arguments, one element per event. * @see #publishEvents(EventTranslator[]) */ public <A, B, C> void publishEvents(EventTranslatorThreeArg<E, A, B, C> translator, A[] arg0, B[] arg1, C[] arg2) { publishEvents(translator, 0, arg0.length, arg0, arg1, arg2); }
/** * Allows three user supplied arguments per event. * * @param translator The user specified translation for the event * @param arg0 An array of user supplied arguments, one element per event. * @param arg1 An array of user supplied arguments, one element per event. * @param arg2 An array of user supplied arguments, one element per event. * @return true if the value was published, false if there was insufficient capacity. * @see #publishEvents(EventTranslator[]) */ public <A, B, C> boolean tryPublishEvents(EventTranslatorThreeArg<E, A, B, C> translator, A[] arg0, B[] arg1, C[] arg2) { return tryPublishEvents(translator, 0, arg0.length, arg0, arg1, arg2); }