Тёмный

Node.js Tutorials - 43 - Microtask Queues 

Codevolution
Подписаться 651 тыс.
Просмотров 43 тыс.
50% 1

⚡️Syncfusion components: syncf.co/3Emhvnv
📘 Courses - learn.codevolution.dev/
💖 Support UPI - support.codevolution.dev/
💖 Support Paypal - www.paypal.me/Codevolution
💾 Github - github.com/gopinav
📱 Follow Codevolution
+ Twitter - / codevolutionweb
+ Facebook - / codevolutionweb
📫 Business - codevolution.business@gmail.com
Microtask Queues
Node.js Tutorial
Node.js Tutorial for Beginners

Опубликовано:

 

13 янв 2023

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 57   
@Invalid_Username404
@Invalid_Username404 11 месяцев назад
Don't know what you have to apologize for. The switches between the diagram and the code are fantastic and help more. Thank you
@muhammedsahad1612
@muhammedsahad1612 11 месяцев назад
The first time I saw the diagram, I skipped the entire tutorial, but after a few months, I started watching it again. The phase and queues in Node JS are now clear to me... thank you so much!
@shorty696820
@shorty696820 Год назад
Your explanation is the clearest one I've ever heard. Thanks a lot!
@spellsaif
@spellsaif Год назад
Your teaching style is so so beautiful that I was able to predict the result. Thank you so much :)
@NyanTint
@NyanTint Год назад
You are one of the best teachers I ever met, sir. Everything explained well and short to the point. Got it in one go and I got my confidence boosted!
@HarshVardhan-tk3ej
@HarshVardhan-tk3ej 9 месяцев назад
Core concepts explained with a heart winning simplicity.
@gregthomas5887
@gregthomas5887 Год назад
I magically got it right on the first try thanks to your great explanations.
@mdsafikulislam7430
@mdsafikulislam7430 Год назад
Sir! You are great in this field!
@user-sf8he5vm2o
@user-sf8he5vm2o 7 месяцев назад
Your teaching style is so so awesome. I'm able to predict the result. Thank you :)😀
@pradneshkhedekar5279
@pradneshkhedekar5279 Год назад
Really great explanation and on point with visual representation 👍
@owethuweek6283
@owethuweek6283 11 месяцев назад
Thanks a lot. You have made my day!
@bytescoder
@bytescoder 5 месяцев назад
Simply outstanding🔥. U made it easy to catch those complex concepts 🎉
@ajilvc5316
@ajilvc5316 2 месяца назад
Thank you so much for this tutorial. It helped me a lot
@nischalbista6436
@nischalbista6436 Год назад
your explanation is soooooo good that I got it right
@Shorts-zd4hn
@Shorts-zd4hn Год назад
It's been wonderful sir, and i got it right in the first try and you made it possible for me to guess
@sahilmistry2898
@sahilmistry2898 Год назад
Greate explanation with patience👌👌
@abdullah-ayyash
@abdullah-ayyash 10 месяцев назад
I always give your video a like before even watching it.
@user-vq4ws5lf3v
@user-vq4ws5lf3v 7 месяцев назад
great job! thank you
@sanjarcode
@sanjarcode Год назад
Thanks a lot, Vishwas
@LearnWithJK03
@LearnWithJK03 Год назад
Just wow concept 🙏🥰
@rokckerzzzz6080
@rokckerzzzz6080 Год назад
Awesome Video...
@mohammedashiq2720
@mohammedashiq2720 Год назад
Well explanation
@faizanahmed9304
@faizanahmed9304 Год назад
Got right man!
@thirunavukarasusaminathan3102
Yes i got the same results
@nithishnaidu5542
@nithishnaidu5542 Месяц назад
11:57 I thought the nested nextTick ("nextTick inside nextTick") will be executed in the next event loop iteration.
@frontend_ko
@frontend_ko Год назад
thanks teacher 43
@MinhLe-ow6op
@MinhLe-ow6op 2 месяца назад
Hi, your explanation is the clearest one I've ever heard. Thank you very much, but can I ask you for this slide for reference?
@natarajanyuvaraj5265
@natarajanyuvaraj5265 Год назад
Got it right
@jivanmainali1742
@jivanmainali1742 5 месяцев назад
How does call stack knows to which queue it should put callbacks to ???
@webstartergurus4463
@webstartergurus4463 2 месяца назад
Hello sir.. i got the promise.resolve.then consoled first before the process.nexttick console
@AlRashidashraf
@AlRashidashraf Год назад
Got right for next tick, but little different for promise.resolve,
@zallesov
@zallesov 9 месяцев назад
Also, I noticed that using Promises puts the execution of the handler to the next cycle. While using regular js callbacks execute right away in for example IO or Timer cycles. Is it fair to say that using callbacks is faster than using Promises? using Promise will add an additional cycle event if it is just Promise.resolve?
@hamza_dev
@hamza_dev 9 месяцев назад
Yes callbacks are a little bit faster but the difference is negligible specially when you consider the elegance and readability promises provide.
@gobicorner
@gobicorner 8 месяцев назад
i got that right
@user-qc9sw4ew3l
@user-qc9sw4ew3l Год назад
According to my understanding, the global function will also be removed from the call stack before running any async code
@igetom
@igetom 8 месяцев назад
no
@privateanon7623
@privateanon7623 9 месяцев назад
The nextTick queue takes precedence over the microtask queue, but the example in (5:50 to 8:35) is only half correct. In fact, if someone runs it as an ESM script (.mjs file or with type="module" in package.json), the output will always be: 2 -> 3 -> 1 That's because instead of executing it synchronously, node schedules it as a microtask callback (like wrapping everything in queueMicroTask(() => { ... }), kind of). So after executing the code, the event loop grabs the next callback in the microtask queue until it becomes empty before checking the nextTick queue. Same thing for the 2nd example. Output for ESM would be: promise 1 promise 2 promise 3 nextTick 1 nextTick 2 nextTick 3 nextTick inside Promise nextTick inside nextTick
@Sarvesh_More
@Sarvesh_More 6 месяцев назад
hey i would really appreciate if you could provide me some reference where i can study about it. This behavior looks confusing.
@privateanon7623
@privateanon7623 6 месяцев назад
@@Sarvesh_More I understand the confusion. The closest thing to a reference that you can get is PR 45093 in the official github repo (/nodejs/node/pull/45093), specifically the review made by devsnek. It's an issue of erroneous documentation in the official docs and unfortunately, the PR addressing it has been stale for more than a year now. But basically, the mental model is the exact same, with the initial code being executed in the microtask queue
@Sarvesh_More
@Sarvesh_More 6 месяцев назад
@@privateanon7623 Thank you.
@pronaypramanick4467
@pronaypramanick4467 Год назад
Hey, I have a question. Why did you repeatedly use the phrase 'user-written synchronous code' in your explanations? Why do we have to mention 'user written'?
@chidimmaokafor7173
@chidimmaokafor7173 Год назад
I am a bit confused. I thought the inner CallBacks would join the next iteration. which would mean the sequence would be NextTick1, NextTick2, NextTick3, PromiseResolve1 PromiseResolve2 PromiseResolve3 NextTick inside NextTick, Promise inside Promise
@privateanon7623
@privateanon7623 9 месяцев назад
That's nextTick/Microtask queues' quirk. The event loop will keep executing all the callbacks of each one until both are empty. You can block your program by abusing this mechanism.
@amankale4692
@amankale4692 Год назад
*space bar* 4:06 ~ "That's what she said". *space bar*
@kalpeshjadvani7358
@kalpeshjadvani7358 4 месяца назад
Promise.resolve().then(() => console.log('start resolved promise')); process.nextTick(() => console.log('start nextTick')); I have run this in my local but bit confusing for me. I am getting [nodemon] restarting due to changes... [nodemon] starting `node justDemo.js` start resolved promise start nextTick [nodemon] clean exit - waiting for changes before restart As you can see I got in same order, not able to understand.
@zallesov
@zallesov 9 месяцев назад
So Calling nextTick inside nextTick actually executes the callback in the same cycle and not in the next.
@privateanon7623
@privateanon7623 9 месяцев назад
It goes beyond that. NextTick and Microtask queues are emptied after every event loop action, rather than phase or iteration.
@iqbalali9796
@iqbalali9796 Год назад
In my case promise queue running before process.nextTick queue
@rishiraj2548
@rishiraj2548 Год назад
🙏👍👍
@andrewshaban2888
@andrewshaban2888 Год назад
Why did they make it so complex? Why do we need so many queues?
@privateanon7623
@privateanon7623 9 месяцев назад
The answer is rather complicated and is related to how operating systems handle each type of task, but in essence, each queue is made for some kind of work that has its own quirks. For example, timers are organized in an ordered heap that puts expired timers in the timers queue, while close functions are low priority and only need to be pushed as they come (FIFO).
@ashokyadavfqplmgxjia4668
@ashokyadavfqplmgxjia4668 4 месяца назад
sir where is your feet i want touch it for it's clear explaination.............thanks sir.........always respect for great teacher.......
@Pareshbpatel
@Pareshbpatel 6 месяцев назад
{2024-01-30}
@theboyIncomfortzone
@theboyIncomfortzone 3 месяца назад
စောက်ပေါ 🤗👍👏👏
@igetom
@igetom 8 месяцев назад
Good tutorial but, god, your ending of all senteces is so annoying
@mohitpal1505
@mohitpal1505 2 месяца назад
Promise.resolve().then(() => console.log("this is Promise 1")); process.nextTick(() => console.log("nextTick 1")); Why output is actually coming : this is Promise 1 nextTick 1
@silentsounds6556
@silentsounds6556 2 месяца назад
same
Далее
Node.js Tutorials - 44 - Timer Queue
10:31
Просмотров 26 тыс.
PROOF JavaScript is a Multi-Threaded language
8:21
Просмотров 271 тыс.
ВОТ ЧТО МЫ КУПИЛИ НА ALIEXPRESS
09:35
What are Message Queues? | BullMQ Queues NodeJS
44:12
Node.js is a serious thing now… (2023)
8:18
Просмотров 636 тыс.
Node.js Tutorial - 61 - Cluster Module
15:10
Просмотров 33 тыс.
I've been using Redis wrong this whole time...
20:53
Просмотров 344 тыс.
RabbitMQ Crash Course
42:53
Просмотров 199 тыс.
ВОТ ЧТО МЫ КУПИЛИ НА ALIEXPRESS
09:35