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


Java Promise.success方法代码示例

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


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

示例1: init

import scala.concurrent.Promise; //导入方法依赖的package包/类
@Override
protected void init(Promise<Void> p) {

    if(connectionLost) {
        return;
    }

    // Enable status updates
    eventBus.setPublishDisabled(false);

    // Schedule drones.simulation loop
    simulationTick = system.scheduler().schedule(
            simulationTimeStep,
            simulationTimeStep,
            self(),
            new StepSimulationMessage(simulationTimeStep),
            system.dispatcher(),
            self());

    initialized = true;
    p.success(null);
}
 
开发者ID:ugent-cros,项目名称:cros-core,代码行数:23,代码来源:BepopSimulator.java

示例2: takeOff

import scala.concurrent.Promise; //导入方法依赖的package包/类
@Override
protected void takeOff(Promise<Void> p) {

    if (prematureExit(p)) {
        return;
    }

    switch (state.getRawValue()) {
        case EMERGENCY:
            p.failure(new DroneException("Drone is in emergency status"));
            break;
        case LANDING:
            // Land drone before taking off again
            setFlyingState(FlyingState.LANDED);
            // Fall-through
        case LANDED:
            setFlyingState(FlyingState.TAKINGOFF);
            setAltitude(1);
            setFlyingState(FlyingState.HOVERING);
            // Fall-through
        default:
            p.success(null);
    }
}
 
开发者ID:ugent-cros,项目名称:cros-core,代码行数:25,代码来源:BepopSimulator.java

示例3: moveToLocation

import scala.concurrent.Promise; //导入方法依赖的package包/类
@Override
final protected void moveToLocation(Promise<Void> v, double latitude, double longitude, double altitude) {
    synchronized (navigationLock) {
        if (navigationState.getRawValue() == NavigationState.IN_PROGRESS) {
            v.failure(new DroneException("Already navigating to " + getNavigator().getGoal() + ", abort this first."));
        } else if (navigationState.getRawValue() == NavigationState.UNAVAILABLE) {
            v.failure(new DroneException("Unable to navigate to goal"));
        } else if (!gpsFix.getRawValue()) {
            v.failure(new DroneException("No GPS fix yet."));
        } else {
            getNavigator().setCurrentLocation(location.getRawValue());
            getNavigator().setGoal(new Location(latitude, longitude, altitude));

            setNavigationState(NavigationState.IN_PROGRESS, NavigationStateReason.REQUESTED);
            v.success(null);
        }
    }
}
 
开发者ID:ugent-cros,项目名称:cros-core,代码行数:19,代码来源:NavigatedDroneActor.java

示例4: setIfAlreadyComplete

import scala.concurrent.Promise; //导入方法依赖的package包/类
private void setIfAlreadyComplete(final String field, Future<?> source,
		final Promise<Object> wait, SetterFailure onFailure) {
	if (source.isCompleted() && !wait.isCompleted()){
		Object returnValue;
		try {
			returnValue = Await.result(source, Duration.create(0, TimeUnit.SECONDS));
			if (returnValue instanceof Null){
				BeanUtils.setProperty(getThis(), field, null);
			} else {
				BeanUtils.setProperty(getThis(), field, returnValue);
			}
		} catch (Exception exception) {
			handleCallbackException(field, onFailure, exception, wait);
		}
		try {
			wait.success(null);
		} catch (IllegalStateException e){}
	}
}
 
开发者ID:ranoble,项目名称:Megapode,代码行数:20,代码来源:WidgetBase.java

示例5: addIfAlreadyComplete

import scala.concurrent.Promise; //导入方法依赖的package包/类
private void addIfAlreadyComplete(final String field, Future<?> source,
		final Promise<Object> wait, SetterFailure onFailure) {
	if (source.isCompleted() && !wait.isCompleted()){
		Object returnValue;
		try {
			returnValue = Await.result(source, Duration.create(0, TimeUnit.SECONDS));
			if (!(returnValue instanceof Null)){
				((List)PropertyUtils.getProperty(getThis(), field)).add(returnValue);
			}
		} catch (Exception exception) {
			handleCallbackException(field, onFailure, exception, wait);
		}
		
		try {
			wait.success(null);
		} catch (IllegalStateException e){}
	}
}
 
开发者ID:ranoble,项目名称:Megapode,代码行数:19,代码来源:WidgetBase.java

示例6: mapPromise

import scala.concurrent.Promise; //导入方法依赖的package包/类
@Benchmark
public String mapPromise() throws Exception {
  Promise<String> p = Promise.<String>apply();
  Future<String> f = p.future().map(mapF, ec);
  p.success(string);
  return Await.result(f, inf);
}
 
开发者ID:traneio,项目名称:future,代码行数:8,代码来源:ScalaFutureBenchmark.java

示例7: mapPromiseN

import scala.concurrent.Promise; //导入方法依赖的package包/类
@Benchmark
public String mapPromiseN() throws Exception {
  Promise<String> p = Promise.<String>apply();
  Future<String> f = p.future();
  for (int i = 0; i < N.n; i++)
    f = f.map(mapF, ec);
  p.success(string);
  return Await.result(f, inf);
}
 
开发者ID:traneio,项目名称:future,代码行数:10,代码来源:ScalaFutureBenchmark.java

示例8: flatMapPromise

import scala.concurrent.Promise; //导入方法依赖的package包/类
@Benchmark
public String flatMapPromise() throws Exception {
  Promise<String> p = Promise.<String>apply();
  Future<String> f = p.future().flatMap(flatMapF, ec);
  p.success(string);
  return Await.result(f, inf);
}
 
开发者ID:traneio,项目名称:future,代码行数:8,代码来源:ScalaFutureBenchmark.java

示例9: flatMapPromiseN

import scala.concurrent.Promise; //导入方法依赖的package包/类
@Benchmark
public String flatMapPromiseN() throws Exception {
  Promise<String> p = Promise.<String>apply();
  Future<String> f = p.future();
  for (int i = 0; i < N.n; i++)
    f = f.flatMap(flatMapF, ec);
  p.success(string);
  return Await.result(f, inf);
}
 
开发者ID:traneio,项目名称:future,代码行数:10,代码来源:ScalaFutureBenchmark.java

示例10: ensurePromise

import scala.concurrent.Promise; //导入方法依赖的package包/类
@Benchmark
public Void ensurePromise() throws Exception {
  Promise<Void> p = Promise.<Void>apply();
  Future<Void> f = p.future().transform(ensureF, ec);
  p.success(null);
  return Await.result(f, inf);
}
 
开发者ID:traneio,项目名称:future,代码行数:8,代码来源:ScalaFutureBenchmark.java

示例11: ensurePromiseN

import scala.concurrent.Promise; //导入方法依赖的package包/类
@Benchmark
public Void ensurePromiseN() throws Exception {
  Promise<Void> p = Promise.<Void>apply();
  Future<Void> f = p.future();
  for (int i = 0; i < N.n; i++)
    f = f.transform(ensureF, ec);
  p.success(null);
  return Await.result(f, inf);
}
 
开发者ID:traneio,项目名称:future,代码行数:10,代码来源:ScalaFutureBenchmark.java

示例12: setValueN

import scala.concurrent.Promise; //导入方法依赖的package包/类
@Benchmark
public String setValueN() throws Exception {
  Promise<String> p = Promise.<String>apply();
  Future<String> f = p.future();
  for (int i = 0; i < N.n; i++)
    f = f.map(mapF, ec);
  p.success(string);
  return Await.result(f, inf);
}
 
开发者ID:traneio,项目名称:future,代码行数:10,代码来源:ScalaFutureBenchmark.java

示例13: onTransactionContextCreated

import scala.concurrent.Promise; //导入方法依赖的package包/类
@Override
protected void onTransactionContextCreated(@Nonnull TransactionIdentifier transactionId) {
    Promise<Object> promise = priorReadOnlyTxPromises.remove(transactionId);
    if (promise != null) {
        promise.success(null);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:8,代码来源:TransactionChainProxy.java

示例14: testAbortWithCohorts

import scala.concurrent.Promise; //导入方法依赖的package包/类
@Test
public void testAbortWithCohorts() throws Exception {
    doReturn(true).when(mockShardDataTree).startAbort(cohort);

    final Promise<Iterable<Object>> cohortFuture = akka.dispatch.Futures.promise();
    doReturn(Optional.of(Collections.singletonList(cohortFuture.future()))).when(mockUserCohorts).abort();

    final Future<?> abortFuture = abort(cohort);

    cohortFuture.success(Collections.emptyList());

    abortFuture.get();
    verify(mockShardDataTree).startAbort(cohort);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:15,代码来源:SimpleShardDataTreeCohortTest.java

示例15: createActorContextMock

import scala.concurrent.Promise; //导入方法依赖的package包/类
private static ActorContext createActorContextMock(final ActorSystem system, final ActorRef actor) {
    final ActorContext mock = mock(ActorContext.class);
    final Promise<PrimaryShardInfo> promise = new scala.concurrent.impl.Promise.DefaultPromise<>();
    final ActorSelection selection = system.actorSelection(actor.path());
    final PrimaryShardInfo shardInfo = new PrimaryShardInfo(selection, (short) 0);
    promise.success(shardInfo);
    when(mock.findPrimaryShardAsync(SHARD)).thenReturn(promise.future());
    return mock;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:10,代码来源:AbstractDataStoreClientBehaviorTest.java


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