Example #1
   * This is the constructor you are looking for.
   * <p>Build a reusable ring configuration object that holds the FROM and ring size definition. We
   * wait to allocate the ring later to support NUMA platforms. In order to wait we require an
   * object to hold this information.
   * <p>Because some messages are made up of multiple fragments and not all fragments are the same
   * size this constructor will make use of the largest fragment defined in the from as the bases
   * for how big to make the primary ring. Once the primary ring is defined we find the fragment
   * with the highest ratio of variable length fields and assume the ring is full of those
   * exclusively. This gives us the maximum number of variable length fields that can be expected
   * which is multiplied by the provided maximumLenghOfVariableLengthFields to get the minimum size
   * of the byte ring. This value is then rounded up to the next power of 2.
   * @param from
   * @param minimumFragmentsOnRing The minimum number of fragments/messages that the application
   *     must be able to put on the ring.
   * @param maximumLenghOfVariableLengthFields
  public PipeConfig(
      FieldReferenceOffsetManager from,
      int minimumFragmentsOnRing,
      int maximumLenghOfVariableLengthFields) {

    int biggestFragment = FieldReferenceOffsetManager.maxFragmentSize(from);
    int primaryMinSize = minimumFragmentsOnRing * biggestFragment;
    this.primaryBits = (byte) (32 - Integer.numberOfLeadingZeros(primaryMinSize - 1));

    int maxVarFieldsInRingAtOnce =
        FieldReferenceOffsetManager.maxVarLenFieldsPerPrimaryRingSize(from, 1 << primaryBits);
    int secondaryMinSize = maxVarFieldsInRingAtOnce * maximumLenghOfVariableLengthFields;
    this.byteBits = (byte) (32 - Integer.numberOfLeadingZeros(secondaryMinSize - 1));

    this.byteConst = null;
    this.from = from;
Example #2
 public PipeConfig(FieldReferenceOffsetManager from) {
   // default size which is smaller than half of 64K because this is the L1 cache size on intel
   // haswell.
   this.primaryBits = 6;
   this.byteBits = 15;
   this.byteConst = null;
   this.from = from;
   // validate
   FieldReferenceOffsetManager.maxVarLenFieldsPerPrimaryRingSize(from, 1 << primaryBits);