本文整理了Java中org.apache.edgent.function.Functions.synchronizedSupplier()
方法的一些代码示例,展示了Functions.synchronizedSupplier()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Functions.synchronizedSupplier()
方法的具体详情如下:
包路径:org.apache.edgent.function.Functions
类名称:Functions
方法名:synchronizedSupplier
[英]Return a thread-safe version of a Supplier function. If the function is guaranteed to be immutable (stateless) then the function is returned, as it is thread safe, otherwise a wrapper is returned that grabs synchronization on function when calling Supplier#get().
If function implements AutoCloseable then the function is assumed to be stateful and a thread-safe version is returned.
[中]返回供应商函数的线程安全版本。如果函数被保证是不可变(无状态)的,则返回该函数,因为它是线程安全的,否则将返回一个包装器,在调用Supplier#get()时获取函数的同步。
如果函数实现了AutoCloseable,则假定该函数是有状态的,并返回线程安全版本。
代码示例来源:origin: apache/incubator-edgent
public EndlessSupplier(Supplier<T> data) {
super(Functions.synchronizedSupplier(data));
}
代码示例来源:origin: org.apache.edgent/edgent-spi-topology
public EndlessSupplier(Supplier<T> data) {
super(Functions.synchronizedSupplier(data));
}
代码示例来源:origin: apache/incubator-edgent
@Override
public <T> TStream<T> poll(Supplier<T> data, long period, TimeUnit unit) {
data = Functions.synchronizedSupplier(data);
return sourceStream(new SupplierPeriodicSource<>(period, unit, data));
}
代码示例来源:origin: org.apache.edgent/edgent-spi-topology
@Override
public <T> TStream<T> source(Supplier<Iterable<T>> data) {
data = Functions.synchronizedSupplier(data);
return sourceStream(new SupplierSource<>(data));
}
代码示例来源:origin: org.apache.edgent/edgent-spi-topology
@Override
public <T> TStream<T> poll(Supplier<T> data, long period, TimeUnit unit) {
data = Functions.synchronizedSupplier(data);
return sourceStream(new SupplierPeriodicSource<>(period, unit, data));
}
代码示例来源:origin: apache/incubator-edgent
@Override
public <T> TStream<T> source(Supplier<Iterable<T>> data) {
data = Functions.synchronizedSupplier(data);
return sourceStream(new SupplierSource<>(data));
}
代码示例来源:origin: apache/incubator-edgent
assertSame(f1, Functions.synchronizedSupplier(f1));
assertSame(f2, Functions.synchronizedSupplier(f2));
int r2 = f2.get();
assertEquals(7, r2);
assertNotSame(f3, Functions.synchronizedSupplier(f3));
Supplier<Integer> f4s = Functions.synchronizedSupplier(f4);
assertNotSame(f4, f4s);
int r4s = f4s.get();
assertNotSame(f5, Functions.synchronizedSupplier(f5));
内容来源于网络,如有侵权,请联系作者删除!