private void translateAndPublishBatch(final EventTranslatorVararg<E> translator, int batchStartsAt, final int batchSize, final long finalSequence, final Object[][] args) { 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++, args[i]); } } finally { sequencer.publish(initialSequence, finalSequence); } }
/** * Allows a variable number of user supplied arguments * * @see #publishEvent(EventTranslator) * @param translator The user specified translation for the event * @param args User supplied arguments. * @return true if the value was published, false if there was insufficient * capacity. */ public boolean tryPublishEvent(EventTranslatorVararg<E> translator, Object...args) { try { final long sequence = sequencer.tryNext(); translateAndPublish(translator, sequence, args); return true; } catch (InsufficientCapacityException e) { return false; } }
/** * Allows a variable number of 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 args User supplied arguments, one Object[] per event. * @return true if the value was published, false if there was insufficient * capacity. * @see #publishEvents(EventTranslator[]) */ public boolean tryPublishEvents(EventTranslatorVararg<E> translator, int batchStartsAt, int batchSize, Object[]... args) { checkBounds(args, batchStartsAt, batchSize); try { final long finalSequence = sequencer.tryNext(batchSize); translateAndPublishBatch(translator, batchStartsAt, batchSize, finalSequence, args); return true; } catch (InsufficientCapacityException e) { return false; } }
private void translateAndPublish(EventTranslatorVararg<E> translator, long sequence, Object...args) { try { translator.translateTo(get(sequence), sequence, args); } finally { sequencer.publish(sequence); } }
/** * Allows a variable number of user supplied arguments * * @see #publishEvent(EventTranslator) * @param translator The user specified translation for the event * @param args User supplied arguments. * @return true if the value was published, false if there was insufficient capacity. */ public boolean tryPublishEvent(EventTranslatorVararg<E> translator, Object... args) { try { final long sequence = sequencer.tryNext(); translateAndPublish(translator, sequence, args); return true; } catch (InsufficientCapacityException e) { return false; } }
/** * Allows a variable number of 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 args User supplied arguments, one Object[] per event. * @return true if the value was published, false if there was insufficient capacity. * @see #publishEvents(EventTranslator[]) */ public boolean tryPublishEvents(EventTranslatorVararg<E> translator, int batchStartsAt, int batchSize, Object[]... args) { checkBounds(args, batchStartsAt, batchSize); try { final long finalSequence = sequencer.tryNext(batchSize); translateAndPublishBatch(translator, batchStartsAt, batchSize, finalSequence, args); return true; } catch (InsufficientCapacityException e) { return false; } }
private void translateAndPublish(EventTranslatorVararg<E> translator, long sequence, Object... args) { try { translator.translateTo(get(sequence), sequence, args); } finally { sequencer.publish(sequence); } }
@Override public void publishEvent(EventTranslatorVararg<ResponseEvent> translator, Object... args) { throw new UnsupportedOperationException(); }
@Override public boolean tryPublishEvent(EventTranslatorVararg<ResponseEvent> translator, Object... args) { throw new UnsupportedOperationException(); }
@Override public void publishEvents(EventTranslatorVararg<ResponseEvent> translator, Object[]... args) { throw new UnsupportedOperationException(); }
@Override public void publishEvents(EventTranslatorVararg<ResponseEvent> translator, int batchStartsAt, int batchSize, Object[]... args) { throw new UnsupportedOperationException(); }
@Override public boolean tryPublishEvents(EventTranslatorVararg<ResponseEvent> translator, Object[]... args) { throw new UnsupportedOperationException(); }
@Override public boolean tryPublishEvents(EventTranslatorVararg<ResponseEvent> translator, int batchStartsAt, int batchSize, Object[]... args) { throw new UnsupportedOperationException(); }
/** * Allows a variable number of 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 args User supplied arguments, one Object[] per event. * @see #publishEvents(EventTranslator[]) */ public void publishEvents(EventTranslatorVararg<E> translator, int batchStartsAt, int batchSize, Object[]... args) { checkBounds(batchStartsAt, batchSize, args); final long finalSequence = sequencer.next(batchSize); translateAndPublishBatch(translator, batchStartsAt, batchSize, finalSequence, args); }
/** * Allows a variable number of user supplied arguments * * @see #publishEvent(EventTranslator) * @param translator The user specified translation for the event * @param args User supplied arguments. */ public void publishEvent(EventTranslatorVararg<E> translator, Object...args) { final long sequence = sequencer.next(); translateAndPublish(translator, sequence, args); }
/** * Allows a variable number of user supplied arguments per event. * * @param translator The user specified translation for the event * @param args User supplied arguments, one Object[] per event. * @see #publishEvents(com.lmax.disruptor.EventTranslator[]) */ public void publishEvents(EventTranslatorVararg<E> translator, Object[]... args) { publishEvents(translator, 0, args.length, args); }
/** * Allows a variable number of user supplied arguments per event. * * @param translator The user specified translation for the event * @param args User supplied arguments, one Object[] per event. * @return true if the value was published, false if there was insufficient * capacity. * @see #publishEvents(com.lmax.disruptor.EventTranslator[]) */ public boolean tryPublishEvents(EventTranslatorVararg<E> translator, Object[]... args) { return tryPublishEvents(translator, 0, args.length, args); }
/** * Allows a variable number of user supplied arguments * * @see #publishEvent(EventTranslator) * @param translator The user specified translation for the event * @param args User supplied arguments. */ public void publishEvent(EventTranslatorVararg<E> translator, Object... args) { final long sequence = sequencer.next(); translateAndPublish(translator, sequence, args); }
/** * Allows a variable number of user supplied arguments per event. * * @param translator The user specified translation for the event * @param args User supplied arguments, one Object[] per event. * @see #publishEvents(EventTranslator[]) */ public void publishEvents(EventTranslatorVararg<E> translator, Object[]... args) { publishEvents(translator, 0, args.length, args); }
/** * Allows a variable number of user supplied arguments per event. * * @param translator The user specified translation for the event * @param args User supplied arguments, one Object[] per event. * @return true if the value was published, false if there was insufficient capacity. * @see #publishEvents(EventTranslator[]) */ public boolean tryPublishEvents(EventTranslatorVararg<E> translator, Object[]... args) { return tryPublishEvents(translator, 0, args.length, args); }