mirror of
https://github.com/jlengrand/vert.x.git
synced 2026-03-10 08:51:19 +00:00
Added promise on VertxInternal to create them from the current context
This commit is contained in:
@@ -352,6 +352,23 @@ public class VertxImpl implements VertxInternal, MetricsProvider {
|
||||
return new TimeoutStreamImpl(delay, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> PromiseInternal<T> promise() {
|
||||
ContextInternal context = getOrCreateContext();
|
||||
return context.promise();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> PromiseInternal<T> promise(Handler<AsyncResult<T>> handler) {
|
||||
if (handler instanceof PromiseInternal) {
|
||||
return (PromiseInternal<T>) handler;
|
||||
} else {
|
||||
PromiseInternal<T> promise = promise();
|
||||
promise.future().setHandler(handler);
|
||||
return promise;
|
||||
}
|
||||
}
|
||||
|
||||
public void runOnContext(Handler<Void> task) {
|
||||
ContextInternal context = getOrCreateContext();
|
||||
context.runOnContext(task);
|
||||
|
||||
@@ -39,6 +39,13 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public interface VertxInternal extends Vertx {
|
||||
|
||||
/**
|
||||
* @return a promise associated with the context returned by {@link #getOrCreateContext()}.
|
||||
*/
|
||||
<T> PromiseInternal<T> promise();
|
||||
|
||||
<T> PromiseInternal<T> promise(Handler<AsyncResult<T>> handler);
|
||||
|
||||
long maxEventLoopExecTime();
|
||||
|
||||
TimeUnit maxEventLoopExecTimeUnit();
|
||||
|
||||
Reference in New Issue
Block a user