CacheSource
This commit is contained in:
@@ -3,8 +3,6 @@
|
|||||||
package org.redkale.source;
|
package org.redkale.source;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.*;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
import org.redkale.annotation.AutoLoad;
|
import org.redkale.annotation.AutoLoad;
|
||||||
import org.redkale.annotation.ResourceListener;
|
import org.redkale.annotation.ResourceListener;
|
||||||
import org.redkale.annotation.ResourceType;
|
import org.redkale.annotation.ResourceType;
|
||||||
@@ -111,32 +109,4 @@ public abstract class AbstractCacheSource extends AbstractService implements Cac
|
|||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <U> CompletableFuture<U> supplyFuture(Supplier<U> supplier) {
|
|
||||||
try {
|
|
||||||
return CompletableFuture.completedFuture(supplier.get());
|
|
||||||
} catch (Throwable t) {
|
|
||||||
return CompletableFuture.failedFuture(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected CompletableFuture<Void> runFuture(Runnable runner) {
|
|
||||||
try {
|
|
||||||
runner.run();
|
|
||||||
return CompletableFuture.completedFuture(null);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
return CompletableFuture.failedFuture(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected <U> CompletableFuture<U> supplyAsync(Supplier<U> supplier) {
|
|
||||||
return CompletableFuture.supplyAsync(supplier);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected <U> CompletableFuture<U> supplyAsync(Supplier<U> supplier, Executor executor) {
|
|
||||||
return CompletableFuture.supplyAsync(supplier, executor);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected CompletableFuture<Void> runAsync(Runnable runner, Executor executor) {
|
|
||||||
return CompletableFuture.runAsync(runner, executor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,6 +193,35 @@ public final class CacheMemorySource extends AbstractCacheSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected <U> CompletableFuture<U> supplyFuture(Supplier<U> supplier) {
|
||||||
|
try {
|
||||||
|
return CompletableFuture.completedFuture(supplier.get());
|
||||||
|
} catch (Throwable t) {
|
||||||
|
return CompletableFuture.failedFuture(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected CompletableFuture<Void> runFuture(Runnable runner) {
|
||||||
|
try {
|
||||||
|
runner.run();
|
||||||
|
return CompletableFuture.completedFuture(null);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
return CompletableFuture.failedFuture(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected <U> CompletableFuture<U> supplyAsync(Supplier<U> supplier) {
|
||||||
|
return CompletableFuture.supplyAsync(supplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected <U> CompletableFuture<U> supplyAsync(Supplier<U> supplier, Executor executor) {
|
||||||
|
return CompletableFuture.supplyAsync(supplier, executor);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected CompletableFuture<Void> runAsync(Runnable runner, Executor executor) {
|
||||||
|
return CompletableFuture.runAsync(runner, executor);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Boolean> isOpenAsync() {
|
public CompletableFuture<Boolean> isOpenAsync() {
|
||||||
return CompletableFuture.completedFuture(true);
|
return CompletableFuture.completedFuture(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user