本文整理了Java中bolts.Task.continueWhile()
方法的一些代码示例,展示了Task.continueWhile()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.continueWhile()
方法的具体详情如下:
包路径:bolts.Task
类名称:Task
方法名:continueWhile
[英]Continues a task with the equivalent of a Task-based while loop, where the body of the loop is a task continuation.
[中]使用相当于基于任务的while循环的方式继续任务,其中循环体是任务的继续。
代码示例来源:origin: parse-community/Parse-SDK-Android
Task<Void> objectsTask = Task.forResult(null).continueWhile(new Callable<Boolean>() {
@Override
public Boolean call() {
代码示例来源:origin: fr.avianey/bolts-android-api
/**
* Continues a task with the equivalent of a Task-based while loop, where the body of the loop is
* a task continuation.
*/
public Task<Void> continueWhile(Callable<Boolean> predicate,
Continuation<Void, Task<Void>> continuation) {
return continueWhile(predicate, continuation, IMMEDIATE_EXECUTOR);
}
代码示例来源:origin: mbientlab/MetaWear-SDK-Android
private Task<Queue<ModuleInfo>> discoverModules(Collection<Constant.Module> ignore) {
final Queue<ModuleInfo> info = new LinkedList<>();
final Queue<Constant.Module> modules = new LinkedList<>();
final Capture<Boolean> terminate = new Capture<>(false);
for(Constant.Module it: Constant.Module.values()) {
if (!ignore.contains(it)) {
modules.add(it);
}
}
return Task.forResult(null).continueWhile(() -> !terminate.get() && !modules.isEmpty(), ignored -> {
final Constant.Module next = modules.poll();
return readModuleInfoTask.execute("Did not receive info for module (" + next.friendlyName + ") within %dms", Constant.RESPONSE_TIMEOUT,
() -> gatt.writeCharacteristicAsync(MW_CMD_GATT_CHAR, WriteType.WITHOUT_RESPONSE, new byte[] { next.id, READ_INFO_REGISTER })
).continueWithTask(task -> {
if (task.isFaulted()) {
terminate.set(true);
return Task.<Void>forError(task.getError());
} else {
info.add(new ModuleInfo(task.getResult()));
return Task.<Void>forResult(null);
}
});
}).continueWithTask(task -> task.isFaulted() ? Task.forError(new TaskTimeoutException(task.getError(), info)) : Task.forResult(info));
}
@Override
代码示例来源:origin: mbientlab/MetaWear-SDK-Android
final Capture<Boolean> terminate = new Capture<>(false);
return Task.forResult(null).continueWhile(() -> !terminate.get() && !eventCodeBlocks.isEmpty(), ignored -> {
Pair<? extends DataTypeBase, ? extends CodeBlock> current = eventCodeBlocks.poll();
return Task.forResult(null).continueWhile(() -> !terminate2.get() && !recordedCommands.isEmpty(), ignored2 -> {
mwPrivate.sendCommand(recordedCommands.poll());
return createEventTask.execute("Did not receive event id within %dms", Constant.RESPONSE_TIMEOUT,
代码示例来源:origin: mbientlab/MetaWear-SDK-Android
final Capture<Boolean> terminate = new Capture<>(false);
return Task.forResult(null).continueWhile(() -> !terminate.get() && !pendingProcessors.isEmpty(), ignored -> {
final Processor current= pendingProcessors.poll();
DataTypeBase input= current.editor.source.input;
代码示例来源:origin: mbientlab/MetaWear-SDK-Android
final Capture<Boolean> terminate = new Capture<>(false);
return Task.forResult(null).continueWhile(() -> !terminate.get() && !producers.isEmpty(), ignored -> {
final DataLogger next = new DataLogger(producers.poll());
final byte[] eventConfig= next.source.eventConfig;
final Capture<Byte> i = new Capture<>((byte) 0);
return Task.forResult(null).continueWhile(() -> !terminate.get() && i.get() < nReqLogIds, ignored2 -> {
final int entrySize= Math.min(remainder.get(), LOG_ENTRY_SIZE), entryOffset= LOG_ENTRY_SIZE * i.get() + next.source.attributes.offset;
代码示例来源:origin: mbientlab/MetaWear-SDK-Android
final Capture<Byte> nextId = new Capture<>(id);
return Task.forResult(null).continueWhile(() -> !terminate.get(), ignored ->
pullProcessorConfigTask.execute("Did not received data processor config within %dms", Constant.RESPONSE_TIMEOUT,
() -> mwPrivate.sendCommand(new byte[] {DATA_PROCESSOR.id, Util.setRead(ADD), nextId.get()})
代码示例来源:origin: mbientlab/MetaWear-SDK-Android
mag = new Capture<>(null);
return Task.forResult(null).continueWhile(() -> !terminate.get(), ignored -> !ct.isCancellationRequested() ? readCalibrationStateAsync().onSuccessTask(task -> {
if (updateHandler != null) {
updateHandler.receivedUpdate(task.getResult());
内容来源于网络,如有侵权,请联系作者删除!