Examples of compareAndSet()


Examples of java.util.concurrent.atomic.AtomicLong.compareAndSet()

            long oldseed, nextseed;
            AtomicLong seed = this.seed;
            do {
                oldseed = seed.get();
                nextseed = (oldseed * multiplier + addend) & mask;
            } while (!seed.compareAndSet(oldseed, nextseed));
            return (int) (nextseed >>> (48 - bits));
        }

        public boolean nextBoolean() {
            return next(1) != 0;
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicLong.compareAndSet()

        long oldseed, nextseed;
        AtomicLong seed = this.seed;
        do {
            oldseed = seed.get();
            nextseed = (oldseed * multiplier + addend) & mask;
        } while (!seed.compareAndSet(oldseed, nextseed));
        return (int) (nextseed >>> (48 - bits));
    }

    public boolean nextBoolean() {
        return next(1) != 0;
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicLongArray.compareAndSet()

            // determine what the new long value will be after we set the appropriate bit.
            long currentLongValue = segment.get(longPosition);
            long newLongValue = currentLongValue | mask;

            // if no other thread has modified the value since we read it, we won the race and we are done.
            if(segment.compareAndSet(longPosition, currentLongValue, newLongValue))
                break;
        }
    }

    public boolean get(int position) {
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicReference.compareAndSet()

                    } catch (InterruptedException ex) {
                        error.set(ex);
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                    error.compareAndSet(null, ex);
                } finally {
                    commitLatch.countDown();
                }
            }
View Full Code Here

Examples of java.util.concurrent.atomic.AtomicReferenceArray.compareAndSet()

        {
            Object candidate = e.getKey();
            if (candidate.equals(key))
            {
                Entry<K, V> replacement = this.createReplacementChainForRemoval((Entry<K, V>) o, e);
                if (currentArray.compareAndSet(index, o, replacement))
                {
                    this.addToSize(-1);
                    return e.getValue();
                }
                return this.slowRemove(key, hash, currentArray);
View Full Code Here

Examples of org.hbase.async.HBaseClient.compareAndSet()

    // Watch this! ______,^ I'm writing C++ in Java!

    when(client_b.atomicIncrement(incrementForRow(MAXID)))
      .thenReturn(Deferred.fromResult(5L));

    when(client_b.compareAndSet(anyPut(), emptyArray()))
      .thenReturn(Deferred.fromResult(true))
      .thenReturn(Deferred.fromResult(true));

    // Now that B is finished, A proceeds and allocates a UID that will be
    // wasted, and creates the reverse mapping, but fails at creating the
View Full Code Here

Examples of org.jgroups.blocks.atomic.Counter.compareAndSet()

                        System.out.println("counter: " + val);
                        break;
                    case '3':
                        long expect=Util.readLongFromStdin("expected value: ");
                        long update=Util.readLongFromStdin("update: ");
                        if(counter.compareAndSet(expect, update)) {
                            System.out.println("-- set counter \"" + counter.getName() + "\" to " + update + "\n");
                        }
                        else {
                            System.err.println("failed setting counter \"" + counter.getName() + "\" from " + expect +
                                                 " to " + update + ", current value is " + counter.get() + "\n");
View Full Code Here

Examples of xbird.util.concurrent.counter.UnsafeIntCounter.compareAndSet()

        do {
            capa = pinning.get();
            if(capa == -1) {// does not pin when the entry is evicted
                return false;
            }
        } while(!pinning.compareAndSet(capa, capa + 1));
        return true;
    }

    public final void unpin() {
        _pinning.decrementAndGet();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.