0

I am a little confused about these two names,are they the same with each other?

Chor
  • 833
  • 1
  • 5
  • 14
  • See https://stackoverflow.com/questions/40880416/what-is-the-difference-between-event-loop-queue-and-job-queue, I think your question is a duplicate of that one. – SteveB Mar 04 '19 at 14:42
  • 1
    https://stackoverflow.com/questions/49729247/javascript-event-loop-queue-vs-message-queue-vs-event-queue and https://stackoverflow.com/questions/40880416/what-is-the-difference-between-event-loop-queue-and-job-queue could be helpful . Maybe also https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop – ADyson Mar 04 '19 at 14:42
  • No a duplicate,they didnt mention task queue which appear in some blogs – Chor Mar 04 '19 at 14:46
  • No-one nominated the above as duplicates, just maybe as potentially interesting or useful reading material to explain the concepts in this area. Which blogs are you seeing "task queue" in...not sure that's a correct/formal piece of terminology being used by the Javascript standards – ADyson Mar 04 '19 at 15:19
  • 2
    An event is something that must be handled, a task is something that can be run. The two terms might accurately describe the kind of data structure that a particular implementation is queueing, or they might be used sloppily and refer to the same thing. After all, an event to trigger a task and a task to handle an event are interchangeable. – Bergi Mar 04 '19 at 15:44

1 Answers1

1

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.

Jonas Wilms
  • 132,000
  • 20
  • 149
  • 151
  • 1
    I would say the term "event queue" is used because actual implementations do put event objects in their queue datastructure, not tasks (units of executable code?). Also the concept is far older than the HTML5 spec. – Bergi Mar 04 '19 at 16:29
  • @bergi well then it makes little sense that the "event loop" is going over "task queues" ... And the HTML5 spec existst as long as I can think, so I can't tell wether any of the terms was coined before .. – Jonas Wilms Mar 04 '19 at 16:45