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


Java AtomicLong.getAndIncrement方法代码示例

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


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

示例1: sendMessageToKafka

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void sendMessageToKafka(String key, DbusMessage dbusMessage, AtomicLong sendCnt, AtomicLong recvCnt, AtomicBoolean isError) throws Exception{
    if(stringProducer == null) {
        throw new Exception("producer is null, can't send to kafka!");
    }

    ProducerRecord record = new ProducerRecord<>(resultTopic, key, dbusMessage.toString());
    sendCnt.getAndIncrement();
    stringProducer.send(record, new Callback() {
        public void onCompletion(RecordMetadata metadata, Exception e) {
            if (e != null) {
                e.printStackTrace();
                isError.set(true);
            }else{
                recvCnt.getAndIncrement();
            }
        }
    });
}
 
开发者ID:BriData,项目名称:DBus,代码行数:20,代码来源:PagedBatchDataFetchingBolt.java

示例2: postCompleteWithRequest

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
@Test
public void postCompleteWithRequest() {
    TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
    ArrayDeque<Integer> queue = new ArrayDeque<Integer>();
    AtomicLong state = new AtomicLong();
    BooleanSupplier isCancelled = new BooleanSupplier() {
        @Override
        public boolean getAsBoolean() throws Exception {
            return false;
        }
    };

    ts.onSubscribe(new BooleanSubscription());
    queue.offer(1);
    state.getAndIncrement();

    QueueDrainHelper.postComplete(ts, queue, state, isCancelled);

    ts.assertResult(1);
}
 
开发者ID:akarnokd,项目名称:RxJava3-preview,代码行数:21,代码来源:QueueDrainHelperTest.java

示例3: postCompleteCancelled

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
@Test
public void postCompleteCancelled() {
    final TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
    ArrayDeque<Integer> queue = new ArrayDeque<Integer>();
    AtomicLong state = new AtomicLong();
    BooleanSupplier isCancelled = new BooleanSupplier() {
        @Override
        public boolean getAsBoolean() throws Exception {
            return ts.isCancelled();
        }
    };

    ts.onSubscribe(new BooleanSubscription());
    queue.offer(1);
    state.getAndIncrement();
    ts.cancel();

    QueueDrainHelper.postComplete(ts, queue, state, isCancelled);

    ts.assertEmpty();
}
 
开发者ID:akarnokd,项目名称:RxJava3-preview,代码行数:22,代码来源:QueueDrainHelperTest.java

示例4: postCompleteCancelledAfterOne

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
@Test
public void postCompleteCancelledAfterOne() {
    final TestSubscriber<Integer> ts = new TestSubscriber<Integer>() {
        @Override
        public void onNext(Integer t) {
            super.onNext(t);
            cancel();
        }
    };
    ArrayDeque<Integer> queue = new ArrayDeque<Integer>();
    AtomicLong state = new AtomicLong();
    BooleanSupplier isCancelled = new BooleanSupplier() {
        @Override
        public boolean getAsBoolean() throws Exception {
            return ts.isCancelled();
        }
    };

    ts.onSubscribe(new BooleanSubscription());
    queue.offer(1);
    state.getAndIncrement();

    QueueDrainHelper.postComplete(ts, queue, state, isCancelled);

    ts.assertValue(1).assertNoErrors().assertNotComplete();
}
 
开发者ID:akarnokd,项目名称:RxJava3-preview,代码行数:27,代码来源:QueueDrainHelperTest.java

示例5: tick

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
void tick() {
    AtomicLong localCounter = this.counter;
    if (localCounter.getAndIncrement() == 0) {
        int emitted = 0;
        do {
            if (this.requested.get() > 0) {
                Object o = this.buffer.poll();
                if (o != null) {
                    if (this.buffer.isCompleted(o)) {
                        this.child.onCompleted();
                    } else {
                        this.buffer.accept(o, this.child);
                        emitted++;
                        this.requested.decrementAndGet();
                    }
                }
            }
        } while (localCounter.decrementAndGet() > 0);
        if (emitted > 0) {
            for (MultiSourceRequestableSubscriber<T, R> s : this.subscribers) {
                s.requestUpTo((long) emitted);
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:26,代码来源:OnSubscribeCombineLatest.java

示例6: getNextSeqNo

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
/**
 * Get the next sequence number for the specified path that includes: table-name, partition/bucket
 * id, time-partition-id
 *
 * @param path the unique path against which the sequence id is maintained
 * @return the next available sequence id
 */
protected long getNextSeqNo(final String path) {
  synchronized (bucketSeqNoMap) {
    AtomicLong mapValue = bucketSeqNoMap.get(path);
    if (mapValue != null) {
      return mapValue.getAndIncrement();
    }
    bucketSeqNoMap.put(path, new AtomicLong(1));
    return 0;
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:18,代码来源:AbstractTierStoreWriter.java

示例7: getNextSeqNo

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
/**
 * Get the next sequence number for the specified path that includes: table-name, partition/bucket
 * id, time-partition-id
 *
 * @param path the unique path against which the sequence id is maintained
 * @return the next available sequence id
 */
public long getNextSeqNo(final String path) {
  synchronized (bucketSeqNoMap) {
    AtomicLong mapValue = bucketSeqNoMap.get(path);
    if (mapValue != null) {
      return mapValue.getAndIncrement();
    }
    bucketSeqNoMap.put(path, new AtomicLong(1));
    return 0;
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:18,代码来源:ORCExternalStoreWriter.java

示例8: getNextSeqNo

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
/**
 * Get next sequence number
 * 
 * @return next sequence number.
 */
public long getNextSeqNo(String tableName, int partitionId) {
  synchronized (bucketSeqNoMap) {
    AtomicLong mapValue = bucketSeqNoMap.get(tableName + "_" + partitionId);
    if (mapValue != null) {
      return mapValue.getAndIncrement();
    }
    bucketSeqNoMap.put(tableName + "_" + partitionId, new AtomicLong(1));
    return 0;
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:16,代码来源:WriteAheadLog.java

示例9: run

import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
public void run() {
    phaser.arriveAndAwaitAdvance();
    phaser.arriveAndAwaitAdvance();
    AtomicLong a = adder;
    for (int i = 0; i < incs; ++i)
        a.getAndIncrement();
    result = a.get();
    phaser.arrive();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:LongAdderDemo.java


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