Event loop refers to an infinite cycle of actions which is used for processing data based on callbacks and messages.
An event loop watches for I/O and timer state changes. It queues functions while waiting for unavailable resources, then dispatches them when resources are available.
I am writing a TCL/Tk application which at some point has a button that eventually runs the following loop:
while {[llength $Queue]>0} {
thread::mutex lock [tsv::set Workers Mutex]
while {[tsv::llength Workers Available]==0} {
…
I have following code snippet in node js
Promise.resolve().then(() => {
Promise.resolve().then(() => console.log('promise'));
process.nextTick(() => console.log('nextTick'));
});
// promise
// nextTick
And I have this…
So I am in the process of migrating a MV2 extension which used persistent Background pages to MV3. In the Chrome migration guide [https://developer.chrome.com/docs/extensions/mv3/migrating_to_service_workers/#event_listeners]
it says :
In order for…
When I run this code in Firefox and Chrome, the results are different:
function run() {
setTimeout(() => console.log("1"), 0);
setTimeout(() => console.log("2"), 100);
let start = Date.now();
while (Date.now() - start < 200) {
// do…
I am running 2 kinds of django web server simultaneously in my architecture, gunicorn(WSGI with worker_class=gevent) and channels(ASGI) respectively.
WSGI server is responsible for handling HTTP request and channels is responsible for websocket…
According to the Node.js DOCs,
when the event-loop enters its poll phase and the poll queue is not empty,
the callbacks in the poll queue should get executed before the event-loop
proceeds further to its check phase.
In reality, however, the…
This is something about the event loop I don't understand.
Here's the code:
async function async1() {
console.log('async1 start');
await async2();
console.log('async1 end');
}
async function async2() {
console.log('async2 start');
…
To my understanding, the point behind await is to 'await' the acting upon the resolved value of a promise until it is encountered as a microtask, as Jake Archibald explains here.
This video by LLJS shows that async-await is essentially syntactical…
In order to dive into more complex concepts about Node.js, I am doing some research to make sure I understand the principles about the language and the basic building blocks it´s build upon.
As far as I´m concerned, Node.js relies in the reactor…
The other day I came across the following peace of code:
let promise = Promise.reject(new Error('Promise Failed!')); // 1
setTimeout(() => promise.catch(err => alert('caught')), 1000); // 2
// 3
So I was quite surprised to find out the error was…
I try to understand event loop of javascript, and I am confused with fetch.
What I know
console.log("1")
Promise.resolve(2)
.then(data => { console.log(data) })
console.log("3")
The above code executes with results: 1, 3, 2. Since in the first…