当前位置: 首页>>代码示例>>Java>>正文


Java AtomicLong.get方法代码示例

本文整理汇总了Java中java.util.concurrent.atomic.AtomicLong.get方法的典型用法代码示例。如果您正苦于以下问题:Java AtomicLong.get方法的具体用法?Java AtomicLong.get怎么用?Java AtomicLong.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.atomic.AtomicLong的用法示例。


在下文中一共展示了AtomicLong.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: emitItem

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
private void emitItem(GroupState<K, T> groupState, Object item) {
    Queue<Object> q = groupState.buffer;
    AtomicLong keyRequested = groupState.requested;
    REQUESTED.decrementAndGet(this);
    if (keyRequested == null || keyRequested.get() <= 0 || !(q == null || q.isEmpty())) {
        q.add(item);
        BUFFERED_COUNT.incrementAndGet(this);
        if (groupState.count.getAndIncrement() == 0) {
            pollQueue(groupState);
        }
    } else {
        nl.accept(groupState.getObserver(), item);
        if (keyRequested.get() != Long.MAX_VALUE) {
            keyRequested.decrementAndGet();
        }
    }
    requestMoreIfNecessary();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:OperatorGroupBy.java

示例2: getPutMessageSizeTotal

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
public long getPutMessageSizeTotal() {
    long rs = 0;
    for (AtomicLong data : putMessageTopicSizeTotal.values()) {
        rs += data.get();
    }
    return rs;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:8,代码来源:StoreStatsService.java

示例3: getPutMessageTimesTotal

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
public long getPutMessageTimesTotal() {
    long rs = 0;
    for (AtomicLong data : putMessageTopicTimesTotal.values()) {
        rs += data.get();
    }
    return rs;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:8,代码来源:StoreStatsService.java

示例4: call

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
public Subscriber<? super T> call(final Subscriber<? super T> child) {
    final AtomicLong requested = new AtomicLong();
    child.setProducer(new Producer() {
        public void request(long n) {
            BackpressureUtils.getAndAddRequest(requested, n);
        }
    });
    return new Subscriber<T>(child) {
        public void onStart() {
            request(Long.MAX_VALUE);
        }

        public void onCompleted() {
            child.onCompleted();
        }

        public void onError(Throwable e) {
            child.onError(e);
        }

        public void onNext(T t) {
            if (requested.get() > 0) {
                child.onNext(t);
                requested.decrementAndGet();
            } else if (OperatorOnBackpressureDrop.this.onDrop != null) {
                OperatorOnBackpressureDrop.this.onDrop.call(t);
            }
        }
    };
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:31,代码来源:OperatorOnBackpressureDrop.java

示例5: updateNumberOfWaits

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
private static void updateNumberOfWaits(AtomicLong start, AtomicLong maxTime) {
    Long now = System.currentTimeMillis();
    Long startValue = start.get();
    if (startValue != 0 && now - startValue > 1000) {
        maxTime.incrementAndGet();
    }
    start.set(now);
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:9,代码来源:BackpressureIntegrationTest.java

示例6: clearBit

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
protected void clearBit(AtomicLong atomic, long lMask) {
    long lWord;
    do {
        lWord = atomic.get();
    } while (!atomic.compareAndSet(lWord, lWord & ~lMask));

    if ((atomic.get() & lMask) != 0L) {
        throw new InternalError();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:Test7009231.java

示例7: deleteAll

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
@Override
public long deleteAll() {
    final Collection<TicketDefinition> metadata = this.ticketCatalog.findAll();
    final AtomicLong count = new AtomicLong();
    metadata.forEach(r -> {
        final IMap<String, Ticket> instance = getTicketMapInstanceByMetadata(r);
        if (instance != null) {
            count.addAndGet(instance.size());
            instance.evictAll();
            instance.clear();
        }
    });
    return count.get();
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:15,代码来源:HazelcastTicketRegistry.java

示例8: setBit

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
protected void setBit(AtomicLong atomic, long lMask) {
    long lWord;
    do {
        lWord = atomic.get();
    } while (!atomic.compareAndSet(lWord, lWord | lMask));

    if ((atomic.get() & lMask) == 0L) {
        throw new InternalError();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:Test7009231.java

示例9: postCompleteRequest

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
/**
 * Accumulates requests (not validated) and handles the completed mode draining of the queue based on the requests.
 *
 * <p>
 * Post-completion backpressure handles the case when a source produces values based on
 * requests when it is active but more values are available even after its completion.
 * In this case, the onComplete() can't just emit the contents of the queue but has to
 * coordinate with the requested amounts. This requires two distinct modes: active and
 * completed. In active mode, requests flow through and the queue is not accessed but
 * in completed mode, requests no-longer reach the upstream but help in draining the queue.
 *
 * @param <T> the value type emitted
 * @param n the request amount, positive (not validated)
 * @param actual the target Subscriber to send events to
 * @param queue the queue to drain if in the post-complete state
 * @param state holds the request amount and the post-completed flag
 * @param isCancelled a supplier that returns true if the drain has been cancelled
 * @return true if the state indicates a completion state.
 */
public static <T> boolean postCompleteRequest(long n,
                                              Subscriber<? super T> actual,
                                              Queue<T> queue,
                                              AtomicLong state,
                                              BooleanSupplier isCancelled) {
    for (; ; ) {
        long r = state.get();

        // extract the current request amount
        long r0 = r & REQUESTED_MASK;

        // preserve COMPLETED_MASK and calculate new requested amount
        long u = (r & COMPLETED_MASK) | BackpressureHelper.addCap(r0, n);

        if (state.compareAndSet(r, u)) {
            // (complete, 0) -> (complete, n) transition then replay
            if (r == COMPLETED_MASK) {

                postCompleteDrain(n | COMPLETED_MASK, actual, queue, state, isCancelled);

                return true;
            }
            // (active, r) -> (active, r + n) transition then continue with requesting from upstream
            return false;
        }
    }

}
 
开发者ID:akarnokd,项目名称:RxJava3-preview,代码行数:48,代码来源:QueueDrainHelper.java

示例10: setNewLargestValue

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
/**
 * 
 * @param value
 * @param newValue
 */
private static boolean setNewLargestValue(AtomicLong value, long newValue) {
  boolean done = false;
  while (!done) {
    long oldValue = value.get();
    if (oldValue < newValue) {
      return value.compareAndSet(oldValue, newValue);
    } else {
      done = true;
    }
  }
  return false;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:18,代码来源:IndexManager.java

示例11: compareAndSetMax

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
public static void compareAndSetMax(final AtomicLong target, final long value) {
    long prev = target.get();
    while (value > prev) {
        boolean updated = target.compareAndSet(prev, value);
        if (updated)
            break;

        prev = target.get();
    }
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:11,代码来源:Consumer.java

示例12: recalculatePullFromWhichNode

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
public long recalculatePullFromWhichNode(final MessageQueue mq) {
    if (this.isConnectBrokerByUser()) {
        return this.defaultBrokerId;
    }

    AtomicLong suggest = this.pullFromWhichNodeTable.get(mq);
    if (suggest != null) {
        return suggest.get();
    }

    return MixAll.MASTER_ID;
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:13,代码来源:PullAPIWrapper.java

示例13: compareAndIncreaseOnly

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
public static boolean compareAndIncreaseOnly(final AtomicLong target, final long value) {
    long prev = target.get();
    while (value > prev) {
        boolean updated = target.compareAndSet(prev, value);
        if (updated)
            return true;

        prev = target.get();
    }

    return false;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:13,代码来源:MixAll.java

示例14: ProducerStat

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
public ProducerStat(String topic, String group, AtomicLong successNums, AtomicLong errorNums,
                    AtomicLong latestSuccessNums, AtomicLong latestErrorNums) {
    super();
    this.topic = topic;
    this.group = group;
    this.successNums = successNums.get();
    this.errorNums = errorNums.get();
    this.latestSuccessNums = latestSuccessNums.get();
    this.latestErrorNums = latestErrorNums.get();
    this.updateTime = System.currentTimeMillis();
}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:12,代码来源:ProducerStat.java

示例15: toString

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
/**
 * Returns a string identifying this pool, as well as its state,
 * including indications of run state, parallelism level, and
 * worker and task counts.
 *
 * @return a string identifying this pool, as well as its state
 */
public String toString() {
    // Use a single pass through workQueues to collect counts
    long qt = 0L, qs = 0L; int rc = 0;
    AtomicLong sc = stealCounter;
    long st = (sc == null) ? 0L : sc.get();
    long c = ctl;
    WorkQueue[] ws; WorkQueue w;
    if ((ws = workQueues) != null) {
        for (int i = 0; i < ws.length; ++i) {
            if ((w = ws[i]) != null) {
                int size = w.queueSize();
                if ((i & 1) == 0)
                    qs += size;
                else {
                    qt += size;
                    st += w.nsteals;
                    if (w.isApparentlyUnblocked())
                        ++rc;
                }
            }
        }
    }
    int pc = (config & SMASK);
    int tc = pc + (short)(c >>> TC_SHIFT);
    int ac = pc + (int)(c >> AC_SHIFT);
    if (ac < 0) // ignore transient negative
        ac = 0;
    int rs = runState;
    String level = ((rs & TERMINATED) != 0 ? "Terminated" :
                    (rs & STOP)       != 0 ? "Terminating" :
                    (rs & SHUTDOWN)   != 0 ? "Shutting down" :
                    "Running");
    return super.toString() +
        "[" + level +
        ", parallelism = " + pc +
        ", size = " + tc +
        ", active = " + ac +
        ", running = " + rc +
        ", steals = " + st +
        ", tasks = " + qt +
        ", submissions = " + qs +
        "]";
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:51,代码来源:ForkJoinPool.java


注:本文中的java.util.concurrent.atomic.AtomicLong.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。