0

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

5
  • See stackoverflow.com/questions/40880416/…, I think your question is a duplicate of that one. Commented Mar 4, 2019 at 14:42
  • 1
    stackoverflow.com/questions/49729247/… and stackoverflow.com/questions/40880416/… could be helpful . Maybe also developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop Commented Mar 4, 2019 at 14:42
  • No a duplicate,they didnt mention task queue which appear in some blogs Commented Mar 4, 2019 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 Commented Mar 4, 2019 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. Commented Mar 4, 2019 at 15:44

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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 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 ..

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.