问题描述
我没有找到关于 @TimeLimiter 注释的确切作用的文档。
是
@TimeLimiter(name = "abc123")
public <T> CompletableFuture<T> execute(supplier<T> supplier) {
return CompletableFuture.supplyAsync(supplier);
}
等于
public <T> CompletableFuture<T> execute(supplier<T> supplier) {
TimeLimiter timeLimiter = timeLimiterRegistry.timeLimiter("abc123");
scheduledexecutorservice scheduler = Executors.newScheduledThreadPool(3); // This scheduler must somehow exist with the annotation as well right?
return timeLimiter.executeCompletionStage(
scheduler,() -> CompletableFuture.supplyAsync(supplier)).toCompletableFuture();
}
代码的非阻塞变体中所需的调度程序,是否以某种方式包含在注释中?
我主要阅读了 here 和这个 blog,但还有其他地方可以让我理解注释的作用吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)