本文整理了Java中io.trane.future.Future.get()
方法的一些代码示例,展示了Future.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Future.get()
方法的具体详情如下:
包路径:io.trane.future.Future
类名称:Future
方法名:get
[英]Blocks the current thread until this future is satisfied and gets its result. This method normally only useful for tests, avoid it for production code.
[中]阻止当前线程,直到满足此未来并获得其结果。此方法通常仅对测试有用,避免用于生产代码。
代码示例来源:origin: traneio/future
@Benchmark
public Integer recursiveConst() throws CheckedFutureException {
return loop(N.n).get(Duration.ofMillis(Long.MAX_VALUE));
}
}
代码示例来源:origin: traneio/future
@Benchmark
public String flatMapConstN() throws CheckedFutureException {
Future<String> f = constFuture;
for (int i = 0; i < N.n; i++)
f = f.flatMap(flatMapF);
return f.get(Duration.ofMillis(Long.MAX_VALUE));
}
代码示例来源:origin: traneio/future
@Benchmark
public Void ensureConstN() throws CheckedFutureException {
Future<Void> f = constVoidFuture;
for (int i = 0; i < N.n; i++)
f = f.ensure(ensureF);
return f.get(Duration.ofMillis(Long.MAX_VALUE));
}
代码示例来源:origin: traneio/future
@Benchmark
public String mapConstN() throws CheckedFutureException {
Future<String> f = constFuture;
for (int i = 0; i < N.n; i++)
f = f.map(mapF);
return f.get(Duration.ofMillis(Long.MAX_VALUE));
}
代码示例来源:origin: traneio/future
@SuppressWarnings("unchecked")
@Override
public final T get(final Duration timeout) throws CheckedFutureException {
final Object curr = state;
if (curr instanceof Future && !(curr instanceof Continuation) && ((Future<T>) curr).isDefined())
return ((Future<T>) curr).get(Duration.ZERO);
else if (curr instanceof LinkedContinuation && ((LinkedContinuation<?, T>) curr).isDefined())
return ((LinkedContinuation<?, T>) curr).get(Duration.ZERO);
else {
join(timeout);
return ((Future<T>) state).get(Duration.ZERO);
}
}
代码示例来源:origin: traneio/ndbc
@Test
public void extendedExecuteDeleteNoParam() throws CheckedFutureException {
final PreparedStatement ps = PreparedStatement.create("DELETE FROM " + table + " WHERE s = 's'");
assertEquals(ds.execute(ps).get(timeout).longValue(), 1L);
final Iterator<Row> rows = ds.query("SELECT * FROM " + table).get(timeout).iterator();
assertFalse(rows.hasNext());
}
代码示例来源:origin: traneio/ndbc
@Test
public void extendedExecuteDeleteWithParam() throws CheckedFutureException {
final PreparedStatement ps = PreparedStatement.create("DELETE FROM " + table + " WHERE s = ?").setString("s");
assertEquals(ds.execute(ps).get(timeout).longValue(), 1L);
final Iterator<Row> rows = ds.query("SELECT * FROM " + table).get(timeout).iterator();
assertFalse(rows.hasNext());
}
代码示例来源:origin: traneio/future
@Benchmark
public String mapPromiseN() throws CheckedFutureException {
Promise<String> p = Promise.<String>apply();
Future<String> f = p;
for (int i = 0; i < N.n; i++)
f = f.map(mapF);
p.setValue(string);
return f.get(Duration.ofMillis(Long.MAX_VALUE));
}
代码示例来源:origin: traneio/future
@Benchmark
public Void ensurePromise() throws CheckedFutureException {
Promise<Void> p = Promise.<Void>apply();
Future<Void> f = p.ensure(ensureF);
p.setValue(null);
return f.get(Duration.ofMillis(Long.MAX_VALUE));
}
代码示例来源:origin: traneio/future
@Benchmark
public String flatMapPromiseN() throws CheckedFutureException {
Promise<String> p = Promise.<String>apply();
Future<String> f = p;
for (int i = 0; i < N.n; i++)
f = f.flatMap(flatMapF);
p.setValue(string);
return f.get(Duration.ofMillis(Long.MAX_VALUE));
}
代码示例来源:origin: traneio/ndbc
@Test
public void simpleExecuteInsert() throws CheckedFutureException {
ds.execute("INSERT INTO " + table + " VALUES ('u')").get(timeout);
final Iterator<Row> rows = ds.query("SELECT * FROM " + table).get(timeout).iterator();
assertEquals(rows.next().column(0).getString(), "s");
assertEquals(rows.next().column(0).getString(), "u");
assertFalse(rows.hasNext());
}
代码示例来源:origin: traneio/future
@Benchmark
public String flatMapPromise() throws CheckedFutureException {
Promise<String> p = Promise.<String>apply();
Future<String> f = p.flatMap(flatMapF);
p.setValue(string);
return f.get(Duration.ofMillis(Long.MAX_VALUE));
}
代码示例来源:origin: traneio/future
@Benchmark
public String setValueN() throws CheckedFutureException {
Promise<String> p = Promise.<String>apply();
Future<String> f = p;
for (int i = 0; i < N.n; i++)
f = f.map(mapF);
p.setValue(string);
return f.get(Duration.ofMillis(Long.MAX_VALUE));
}
代码示例来源:origin: traneio/future
@Benchmark
public String mapPromise() throws CheckedFutureException {
Promise<String> p = Promise.<String>apply();
Future<String> f = p.map(mapF);
p.setValue(string);
return f.get(Duration.ofMillis(Long.MAX_VALUE));
}
代码示例来源:origin: traneio/future
@Benchmark
public Void ensurePromiseN() throws CheckedFutureException {
Promise<Void> p = Promise.apply();
Future<Void> f = p;
for (int i = 0; i < N.n; i++)
f = f.ensure(ensureF);
p.setValue(null);
return f.get(Duration.ofMillis(Long.MAX_VALUE));
}
代码示例来源:origin: traneio/ndbc
@Test
public void simpleQueryInvalid() throws CheckedFutureException {
try {
ds.query("SLCT * FROM " + table).get(timeout);
assertTrue(false);
} catch (final NdbcException ex) {
}
}
代码示例来源:origin: traneio/ndbc
@Test
public void extendedExecuteInsertWithParam() throws CheckedFutureException {
final PreparedStatement ps = PreparedStatement.create("INSERT INTO " + table + " VALUES (?)").setString("u");
assertEquals(ds.execute(ps).get(timeout).longValue(), 1L);
final Iterator<Row> rows = ds.query("SELECT * FROM " + table).get(timeout).iterator();
assertEquals(rows.next().column(0).getString(), "s");
assertEquals(rows.next().column(0).getString(), "u");
assertFalse(rows.hasNext());
}
代码示例来源:origin: traneio/ndbc
@Test
public void simpleExecuteDeleteFailure() throws CheckedFutureException {
try {
ds.execute("DELETE FROM invalid_table").get(timeout);
assertTrue(false);
} catch (final NdbcException ex) {
assertTrue(ex.getMessage().contains("invalid_table"));
}
}
代码示例来源:origin: traneio/ndbc
@Test
public void transactionDBFailure() throws CheckedFutureException {
final PreparedStatement ps = PreparedStatement.create("DELETE FROM INVALID_TABLE WHERE s = ?").setString("s");
ds.transactional(() -> ds.execute(ps)).join(timeout);
final Iterator<Row> rows = ds.query("SELECT * FROM " + table).get(timeout).iterator();
assertTrue(rows.hasNext());
}
代码示例来源:origin: traneio/ndbc
@Test
public void extendedExecuteDeleteWithParamFailure() throws CheckedFutureException {
final PreparedStatement ps = PreparedStatement.create("DELETE FROM invalid_table WHERE s = ?").setString("s");
try {
ds.execute(ps).get(timeout);
assertTrue(false);
} catch (final NdbcException ex) {
assertTrue(ex.getMessage().contains("invalid_table"));
}
}
内容来源于网络,如有侵权,请联系作者删除!