简体   繁体   中英

Is there any difference between event queue and task queue?

我对这两个名字有些困惑,它们彼此相同吗?

There is no "event queue" in ECMAScript, there is also no "event loop" and no "task queue".

The ES262 specification only says:

8.4 Jobs and Job Queues

A Job is an abstract operation that initiates an ECMAScript computation when no other ECMAScript computation is currently in progress. A Job abstract operation may be defined to accept an arbitrary set of job parameters. Execution of a Job can be initiated only when there is no running execution context and the execution context stack is empty. A PendingJob is a request for the future execution of a Job

[...]

A request for the future execution of a Job is made by enqueueing, on a Job Queue, a PendingJob record that includes a Job abstract operation name and any necessary argument values.

In ECMAScript, there are only two Job queues, one for promise resolution and one for the initial loading of modules / code, however the spec allows more queues to be defined explicitly.

Everything else is not defined by ECMAScript itself, but is defined by the runtime implementations or by other specifications.


The "task queues" you were talking about are an example for that:

They are defined for webrowsers as ES job queues for browser specific events. This Specification also coins the term "event loop" (which is also a common term) to describe the logic that empties the job queues.

Therefore "event queue" is probably used because

a) it simplifies the concept of multiple job queues if you say that there is "one event loop" that empties "one event queue".

b) people never read the specs.

c) the term was coined and never specified.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM