eclipse-vertx / vert.x

Vert.x is a tool-kit for building reactive applications on the JVM
http://vertx.io
Other
14.26k stars 2.07k forks source link

Calling Future#await() from a non vertx thread should be allowed. #5300

Closed vietj closed 2 weeks ago

vietj commented 2 weeks ago

Motivation:

Future#await() was initially meant to be called by a vertx virtual thread and reject any other thread. However this method can facilitate the workflow of synchrononous thread interacting with a vertx runtime, e.g. a unit test, from non-vertx threads.

Changes:

Change the implementation of Future#await() to permit non-vertx thread to block until the future completes. In addition a variant with a timeout has been added which can be useful for testing.

Results:

Any non-vertx thread can now await a future.