Search in sources :

Example 11 with AtomicLongArray

use of java.util.concurrent.atomic.AtomicLongArray in project intellij-community by JetBrains.

the class ConcurrentBitSet method equals.

/**
  * Compares this object against the specified object.
  * The result is {@code true} if and only if the argument is
  * not {@code null} and is a {@code ConcurrentBitSet} object that has
  * exactly the same set of bits set to {@code true} as this bit
  * set. That is, for every nonnegative {@code int} index {@code k},
  * <pre>((ConcurrentBitSet)obj).get(k) == this.get(k)</pre>
  * must be true. The current sizes of the two bit sets are not compared.
  *
  * @param obj the object to compare with
  * @return {@code true} if the objects are the same;
  * {@code false} otherwise
  * @see #size()
  */
@Override
public boolean equals(Object obj) {
    if (!(obj instanceof ConcurrentBitSet)) {
        return false;
    }
    if (this == obj) {
        return true;
    }
    ConcurrentBitSet set = (ConcurrentBitSet) obj;
    for (int i = 0; i < arrays.length(); i++) {
        AtomicLongArray array1 = arrays.get(i);
        AtomicLongArray array2 = set.arrays.get(i);
        if (array1 == null && array2 == null)
            continue;
        int size = array1 == null ? array2.length() : array1.length();
        for (int k = 0; k < size; k++) {
            long word1 = array1 == null ? 0 : array1.get(k);
            long word2 = array2 == null ? 0 : array2.get(k);
            if (word1 != word2)
                return false;
        }
    }
    return true;
}
Also used : AtomicLongArray(java.util.concurrent.atomic.AtomicLongArray)

Example 12 with AtomicLongArray

use of java.util.concurrent.atomic.AtomicLongArray in project intellij-community by JetBrains.

the class ConcurrentBitSet method getOrCreateArray.

@NotNull
private AtomicLongArray getOrCreateArray(int bitIndex) {
    int arrayIndex = arrayIndex(bitIndex);
    AtomicLongArray array;
    // while loop is here because of clear() method
    while ((array = arrays.get(arrayIndex)) == null) {
        arrays.compareAndSet(arrayIndex, null, new AtomicLongArray(1 << arrayIndex));
    }
    return array;
}
Also used : AtomicLongArray(java.util.concurrent.atomic.AtomicLongArray) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with AtomicLongArray

use of java.util.concurrent.atomic.AtomicLongArray in project intellij-community by JetBrains.

the class ConcurrentBitSet method changeWord.

long changeWord(int bitIndex, @NotNull TLongFunction change) {
    if (bitIndex < 0) {
        throw new IndexOutOfBoundsException("bitIndex < 0: " + bitIndex);
    }
    AtomicLongArray array = getOrCreateArray(bitIndex);
    int wordIndexInArray = wordIndexInArray(bitIndex);
    long word;
    long newWord;
    do {
        word = array.get(wordIndexInArray);
        newWord = change.execute(word);
    } while (!array.compareAndSet(wordIndexInArray, word, newWord));
    return word;
}
Also used : AtomicLongArray(java.util.concurrent.atomic.AtomicLongArray)

Example 14 with AtomicLongArray

use of java.util.concurrent.atomic.AtomicLongArray in project guava by google.

the class AtomicDoubleArray method readObject.

/**
   * Reconstitutes the instance from a stream (that is, deserializes it).
   */
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {
    s.defaultReadObject();
    // Read in array length and allocate array
    int length = s.readInt();
    this.longs = new AtomicLongArray(length);
    // Read in all elements in the proper order.
    for (int i = 0; i < length; i++) {
        set(i, s.readDouble());
    }
}
Also used : AtomicLongArray(java.util.concurrent.atomic.AtomicLongArray)

Example 15 with AtomicLongArray

use of java.util.concurrent.atomic.AtomicLongArray in project guava by hceylan.

the class AtomicDoubleArray method readObject.

/**
   * Reconstitutes the instance from a stream (that is, deserializes it).
   */
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {
    s.defaultReadObject();
    // Read in array length and allocate array
    int length = s.readInt();
    this.longs = new AtomicLongArray(length);
    // Read in all elements in the proper order.
    for (int i = 0; i < length; i++) {
        set(i, s.readDouble());
    }
}
Also used : AtomicLongArray(java.util.concurrent.atomic.AtomicLongArray)

Aggregations

AtomicLongArray (java.util.concurrent.atomic.AtomicLongArray)22 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 Random (java.util.Random)2 AtomicIntegerArray (java.util.concurrent.atomic.AtomicIntegerArray)2 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)2 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 GridRandom (org.apache.ignite.internal.util.GridRandom)2 NotNull (org.jetbrains.annotations.NotNull)2 Test (org.junit.Test)2 Deadline (scala.concurrent.duration.Deadline)2 ActorRef (akka.actor.ActorRef)1 ActorSystem (akka.actor.ActorSystem)1 JSONArray (com.alibaba.fastjson.JSONArray)1 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1