Codota Logo
Pow2.roundToPowerOfTwo
Code IndexAdd Codota to your IDE (free)

How to use
roundToPowerOfTwo
method
in
org.jctools.util.Pow2

Best Java code snippets using org.jctools.util.Pow2.roundToPowerOfTwo (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Gson g =
  • Codota Iconnew Gson()
  • Codota IconGsonBuilder gsonBuilder;gsonBuilder.create()
  • Codota Iconnew GsonBuilder().create()
  • Smart code suggestions by Codota
}
origin: JCTools/JCTools

@SuppressWarnings("unchecked")
public IdentityOpenHashSet(int capacity) {
  int actualCapacity = Pow2.roundToPowerOfTwo(capacity);
  // pad data on either end with some empty slots?
  buffer = (E[]) new Object[actualCapacity];
  resizeThreshold = (int) (0.75 * buffer.length);
}
origin: JCTools/JCTools

@SuppressWarnings("unchecked")
public ConcurrentCircularArray(int capacity) {
  int actualCapacity = Pow2.roundToPowerOfTwo(capacity);
  mask = actualCapacity - 1;
  // pad data on either end with some empty slots.
  buffer = (E[]) new Object[(actualCapacity << SPARSE_SHIFT) + BUFFER_PAD * 2];
}
origin: JCTools/JCTools

  protected FixedSizeStripedLongCounterFields(int stripesCount) {
    if (stripesCount <= 0) {
      throw new IllegalArgumentException("Expecting a stripesCount that is larger than 0");
    }
    int size = Pow2.roundToPowerOfTwo(stripesCount);
    cells = new long[CACHE_LINE_IN_LONGS * size];
    mask = (size - 1);
  }
}
origin: JCTools/JCTools

  MpscChunkedAtomicArrayQueueColdProducerFields(int initialCapacity, int maxCapacity) {
    super(initialCapacity);
    RangeUtil.checkGreaterThanOrEqual(maxCapacity, 4, "maxCapacity");
    RangeUtil.checkLessThan(roundToPowerOfTwo(initialCapacity), roundToPowerOfTwo(maxCapacity), "initialCapacity");
    maxQueueCapacity = ((long) Pow2.roundToPowerOfTwo(maxCapacity)) << 1;
  }
}
origin: JCTools/JCTools

ConcurrentCircularArrayQueue(int capacity)
{
  int actualCapacity = Pow2.roundToPowerOfTwo(capacity);
  mask = actualCapacity - 1;
  buffer = CircularArrayOffsetCalculator.allocate(actualCapacity);
}
origin: JCTools/JCTools

public SpscUnboundedAtomicArrayQueue(int chunkSize) {
  int chunkCapacity = Math.max(Pow2.roundToPowerOfTwo(chunkSize), 16);
  long mask = chunkCapacity - 1;
  AtomicReferenceArray<E> buffer = allocate(chunkCapacity + 1);
  producerBuffer = buffer;
  producerMask = mask;
  consumerBuffer = buffer;
  consumerMask = mask;
  // we know it's all empty to start with
  producerBufferLimit = mask - 1;
}
origin: JCTools/JCTools

  @SuppressWarnings("unchecked")
  protected BQueueColdFields(int capacity) {
    if (Pow2.isPowerOfTwo(capacity)) {
      this.capacity = capacity;
    } else {
      this.capacity = Pow2.roundToPowerOfTwo(capacity);
    }
    mask = this.capacity - 1;
    buffer = (E[]) new Object[this.capacity + BUFFER_PAD * 2];
  }
}
origin: JCTools/JCTools

  @SuppressWarnings("unchecked")
  InlinedRingBufferColdFields(int capacity) {
    if (Pow2.isPowerOfTwo(capacity)) {
      this.capacity = capacity;
    } else {
      this.capacity = Pow2.roundToPowerOfTwo(capacity);
    }
    mask = this.capacity - 1;
    buffer = (E[]) new Object[(this.capacity << SPARSE_SHIFT) + BUFFER_PAD * 2];
  }
}
origin: JCTools/JCTools

public MpscBlockingConsumerArrayQueue(final int capacity)
{
  // leave lower bit of mask clear
  super((long) ((Pow2.roundToPowerOfTwo(capacity) - 1) << 1), 
    (E[])allocate(Pow2.roundToPowerOfTwo(capacity)));
  
  RangeUtil.checkGreaterThanOrEqual(capacity, 1, "capacity");
  soProducerLimit((long) ((Pow2.roundToPowerOfTwo(capacity) - 1) << 1)); // we know it's all empty to start with
}
origin: JCTools/JCTools

@SuppressWarnings("unchecked")
public MpmcConcurrentQueueSMBuffer(int capacity) {
  if (Pow2.isPowerOfTwo(capacity)) {
    this.capacity = capacity;
  } else {
    this.capacity = Pow2.roundToPowerOfTwo(capacity);
  }
  mask = this.capacity - 1;
  // pad data on either end with some empty slots.
  buffer = (E[]) new Object[(this.capacity << SPARSE_SHIFT) + BUFFER_PAD * 2];
}
origin: JCTools/JCTools

  @SuppressWarnings("unchecked")
  FloatingCaqColdFields(int capacity) {
    if (Pow2.isPowerOfTwo(capacity)) {
      this.capacity = capacity;
    } else {
      this.capacity = Pow2.roundToPowerOfTwo(capacity);
    }
    mask = this.capacity - 1;
    buffer = (E[]) new Object[(this.capacity << SPARSE_SHIFT) + BUFFER_PAD * 2];
  }
}
origin: JCTools/JCTools

public SpscUnboundedArrayQueue(int chunkSize)
{
  int chunkCapacity = Math.max(Pow2.roundToPowerOfTwo(chunkSize), 16);
  long mask = chunkCapacity - 1;
  E[] buffer = allocate(chunkCapacity + 1);
  producerBuffer = buffer;
  producerMask = mask;
  consumerBuffer = buffer;
  consumerMask = mask;
  producerBufferLimit = mask - 1; // we know it's all empty to start with
}
origin: JCTools/JCTools

public SpscOffHeapIntQueue(final int capacity) {
  this(allocateAlignedByteBuffer(
      getRequiredBufferSize(capacity),
      PortableJvmInfo.CACHE_LINE_SIZE),
      Pow2.roundToPowerOfTwo(capacity),(byte)(PRODUCER | CONSUMER));
}
origin: JCTools/JCTools

public OffHeapFixedMessageSizeRingBuffer(final int capacity, final int primitiveMessageSize, int referenceMessageSize) {
  this(allocateAlignedByteBuffer(getRequiredBufferSize(capacity, primitiveMessageSize), CACHE_LINE_SIZE), 
      Pow2.roundToPowerOfTwo(capacity),
      true,
      true,
      true,
      primitiveMessageSize,
      createReferenceArray(capacity, referenceMessageSize),
      referenceMessageSize);
}
origin: JCTools/JCTools

public MpscOffHeapFixedSizeRingBuffer(final int capacity, final int messageSize, int referenceMessageSize) {
  this(allocateAlignedByteBuffer(getRequiredBufferSize(capacity, messageSize), PortableJvmInfo.CACHE_LINE_SIZE),
      Pow2.roundToPowerOfTwo(capacity),
      true,
      true,
      true,
      messageSize,
      createReferenceArray(capacity, referenceMessageSize),
      referenceMessageSize);
}
origin: JCTools/JCTools

  @Parameterized.Parameters
  public static Collection<Object[]> parameters()
  {
    ArrayList<Object[]> list = new ArrayList<Object[]>();
    list.add(makeAtomic(0, 1, Pow2.roundToPowerOfTwo(CPUs), Ordering.NONE, null));// MPSC size 1
    list.add(makeAtomic(0, 1, SIZE, Ordering.NONE, null));// MPSC size SIZE
    return list;
  }
}
origin: JCTools/JCTools

  @Parameterized.Parameters
  public static Collection<Object[]> parameters()
  {
    ArrayList<Object[]> list = new ArrayList<Object[]>();
    list.add(makeMpq(0, 1, Pow2.roundToPowerOfTwo(CPUs), Ordering.NONE, null));// MPSC size 1
    list.add(makeMpq(0, 1, SIZE, Ordering.NONE, null));// MPSC size SIZE
    return list;
  }
}
origin: JCTools/JCTools

@Test(expected = IllegalArgumentException.class)
public void testMaxRoundException()
{
  Pow2.roundToPowerOfTwo(MAX_POSITIVE_POW2 + 1);
  fail();
}
origin: ben-manes/caffeine

@Test
public void testPowerOf2Capacity() {
 assumeThat(spec.isBounded(), is(true));
 int n = Pow2.roundToPowerOfTwo(spec.capacity);
 for (int i = 0; i < n; i++) {
  assertTrue("Failed to insert:" + i, queue.offer(i));
 }
 assertFalse(queue.offer(n));
}
origin: JCTools/JCTools

@Test
public void testPowerOf2Capacity()
{
  assumeThat(spec.isBounded(), is(true));
  int n = Pow2.roundToPowerOfTwo(spec.capacity);
  for (int i = 0; i < n; i++)
  {
    assertTrue("Failed to insert:" + i, queue.relaxedOffer(i));
  }
  assertFalse(queue.relaxedOffer(n));
}
org.jctools.utilPow2roundToPowerOfTwo

Popular methods of Pow2

  • align
    Align a value to the next multiple up of alignment. If the value equals an alignment multiple then i
  • isPowerOfTwo

Popular in Java

  • Finding current android device location
  • setRequestProperty (URLConnection)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • runOnUiThread (Activity)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • BitSet (java.util)
    This class implements a vector of bits that grows as needed. Each component of the bit set has a boo
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now