TunnelManager: Enumerate running tunnels only once
Signed-off-by: Samuel Holland <samuel@sholland.org>
This commit is contained in:
parent
df7d18fb5d
commit
2315a699fb
@ -87,13 +87,11 @@ public final class TunnelManager {
|
|||||||
|
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
Log.v(TAG, "onCreate triggered");
|
Log.v(TAG, "onCreate triggered");
|
||||||
configStore.enumerate()
|
configStore.enumerate().thenAcceptBoth(backend.enumerate(), (names, running) -> {
|
||||||
.thenApply(names -> StreamSupport.stream(names)
|
for (final String name : names) {
|
||||||
.map(this::add)
|
add(name, null, running.contains(name) ? State.UP : State.DOWN);
|
||||||
.map(Tunnel::getStateAsync)
|
}
|
||||||
.toArray(CompletableFuture[]::new))
|
}).whenComplete(ExceptionLoggers.D);
|
||||||
.thenCompose(CompletableFuture::allOf)
|
|
||||||
.whenComplete(ExceptionLoggers.E);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletionStage<Void> restoreState() {
|
public CompletionStage<Void> restoreState() {
|
||||||
|
Loading…
Reference in New Issue
Block a user