vert.x 是否在分配给同一事件循环的 Verticles 之间提供公平的调度?

Does vert.x provide a fair scheduling between verticles assigned to same event loop?

有人知道vert.x是如何处理以下情况的吗?

Verticle B 的执行是否会等待 A 的所有队列完成?

文档对这方面并不清楚。

以下是文档的一些摘录:http://vertx.io/manual.html#event-loops

When a standard verticle instance is deployed, the server chooses an event loop which will be assigned to that instance. Any subsequent work to be done for that instance will always be dispatched using that exact thread. Of course, since there are potentially many thousands of verticles running at any one time, a single event loop will be assigned to many verticles at the same time.

We call this the multi-reactor pattern. It's like the reactor pattern but there's more than one event loop.

谢谢, 米海

我不会谈论 "cpu events",而是谈论一般事件。 如果两个 Verticle 都分配给同一个事件循环并且事件按照您所说的顺序排队,它们将以这种方式执行 - 没有事件优先级:事件按照它们在队列中的顺序处理。

然而,这种情况不太可能发生,vert.x 中重要的是每个处理程序都不会阻塞事件循环——理想情况下,每个 verticle/handler 应该花费很少的 cpu 时间保持平台的活力

HTH,
卡罗

Vert.x 事件循环是来自 Netty 的 NioEventLoop。事件循环线程要执行的任务在 MpscLinkedQueue 中排队,这是一个 single-consumer/multi-producer 队列。

这意味着计划执行的任务将按提交的顺序进行处理。

但是,如果一个 Verticle 有多个实例(它们都是相同事件的可能消费者),则会应用循环调度以在消费者之间平均分配传入事件。