Java Code Examples for io.vertx.core.Future#fromCompletionStage()

The following examples show how to use io.vertx.core.Future#fromCompletionStage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InfinispanAsyncMapImpl.java    From vertx-infinispan with Apache License 2.0 5 votes vote down vote up
@Override
public Future<Boolean> replaceIfPresent(K k, V oldValue, V newValue) {
  byte[] kk = DataConverter.toCachedObject(k);
  byte[] oo = DataConverter.toCachedObject(oldValue);
  byte[] nn = DataConverter.toCachedObject(newValue);
  return Future.fromCompletionStage(cache.replaceAsync(kk, oo, nn), vertx.getOrCreateContext());
}
 
Example 2
Source File: HazelcastAsyncMap.java    From vertx-hazelcast with Apache License 2.0 5 votes vote down vote up
@Override
public Future<Void> put(K k, V v) {
  K kk = convertParam(k);
  V vv = convertParam(v);
  ContextInternal context = vertx.getOrCreateContext();
  return Future.fromCompletionStage(map.setAsync(kk, HazelcastServerID.convertServerID(vv)), context);
}
 
Example 3
Source File: HazelcastAsyncMap.java    From vertx-hazelcast with Apache License 2.0 5 votes vote down vote up
@Override
public Future<Void> put(K k, V v, long ttl) {
  K kk = convertParam(k);
  V vv = convertParam(v);
  ContextInternal context = vertx.getOrCreateContext();
  CompletionStage<Void> completionStage = map.setAsync(kk, HazelcastServerID.convertServerID(vv), ttl, MILLISECONDS);
  return Future.fromCompletionStage(completionStage, context);
}
 
Example 4
Source File: InfinispanAsyncMapImpl.java    From vertx-infinispan with Apache License 2.0 4 votes vote down vote up
@Override
public Future<Boolean> removeIfPresent(K k, V v) {
  byte[] kk = DataConverter.toCachedObject(k);
  byte[] vv = DataConverter.toCachedObject(v);
  return Future.fromCompletionStage(cache.removeAsync(kk, vv), vertx.getOrCreateContext());
}
 
Example 5
Source File: InfinispanAsyncMapImpl.java    From vertx-infinispan with Apache License 2.0 4 votes vote down vote up
@Override
public Future<Void> clear() {
  return Future.fromCompletionStage(cache.clearAsync(), vertx.getOrCreateContext());
}
 
Example 6
Source File: HazelcastCounter.java    From vertx-hazelcast with Apache License 2.0 4 votes vote down vote up
@Override
public Future<Long> get() {
  return Future.fromCompletionStage(atomicLong.getAsync(), vertx.getOrCreateContext());
}
 
Example 7
Source File: HazelcastCounter.java    From vertx-hazelcast with Apache License 2.0 4 votes vote down vote up
@Override
public Future<Long> incrementAndGet() {
  return Future.fromCompletionStage(atomicLong.incrementAndGetAsync(), vertx.getOrCreateContext());
}
 
Example 8
Source File: HazelcastCounter.java    From vertx-hazelcast with Apache License 2.0 4 votes vote down vote up
@Override
public Future<Long> getAndIncrement() {
  return Future.fromCompletionStage(atomicLong.getAndIncrementAsync(), vertx.getOrCreateContext());
}
 
Example 9
Source File: HazelcastCounter.java    From vertx-hazelcast with Apache License 2.0 4 votes vote down vote up
@Override
public Future<Long> decrementAndGet() {
  return Future.fromCompletionStage(atomicLong.decrementAndGetAsync(), vertx.getOrCreateContext());
}
 
Example 10
Source File: HazelcastCounter.java    From vertx-hazelcast with Apache License 2.0 4 votes vote down vote up
@Override
public Future<Long> addAndGet(long value) {
  return Future.fromCompletionStage(atomicLong.addAndGetAsync(value), vertx.getOrCreateContext());
}
 
Example 11
Source File: HazelcastCounter.java    From vertx-hazelcast with Apache License 2.0 4 votes vote down vote up
@Override
public Future<Long> getAndAdd(long value) {
  return Future.fromCompletionStage(atomicLong.getAndAddAsync(value), vertx.getOrCreateContext());
}
 
Example 12
Source File: HazelcastCounter.java    From vertx-hazelcast with Apache License 2.0 4 votes vote down vote up
@Override
public Future<Boolean> compareAndSet(long expected, long value) {
  return Future.fromCompletionStage(atomicLong.compareAndSetAsync(expected, value), vertx.getOrCreateContext());
}