难道JS使用非阻塞I / O在OS层面支持AJAX? [英] Do JS use Non blocking I/O at OS level to support AJAX?

查看:218
本文介绍了难道JS使用非阻塞I / O在OS层面支持AJAX?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果JavaScript是一种单线程程序和AJAX异步那么它是如何发生的呢? 因此,在操作系统级别是不是JS引擎使得非阻塞I / O调用Ajax的?

If Javascript is a single threaded process and AJAX is asynchronous then how does it happen ? So at OS level ain't the JS engine making a Non-Blocking I/O call for Ajax ?

推荐答案

是的,浏览器引擎正在非阻塞I / O调用阿贾克斯(当你做一个非阻塞AJAX调用)。

Yes, the browser engine is making a non-blocking I/O call for Ajax (when you do a non-blocking ajax call).

有任何数量的不同方式,浏览器可以实现的AJAX联网。我们确切知道的唯一的事情是,AJAX I / O请求不堵的JavaScript线程。而且,进一步的每一个浏览器是免费的不同,只要他们不阻止JS执行线程,需要在Ajax调用期间保持浏览器功能的任何其他线程来实现它。

There are any number of different ways the browser could implement the ajax networking. The only thing we know for sure is that the ajax i/o request isn't blocking the javascript thread. And, further every browser is free to implement it differently as long as they don't block the JS execution thread and any other threads needed to keep the browser functional during the ajax call.

在幕后,在浏览器中,它可能是使用一个单独的操作系统线程运行在阻塞的方式在该线程的AJAX调用,它可以使用非阻塞I / O上的一个单独的线程,也可能是使用非阻塞I / O的JavaScript跨preTER线程(可能是不可能的,但有可能)上。甚至可以使用一个独立的进程来管理网络操作符合IPC它们之间通信。它选用的是完全由浏览器执行任何这些方法将允许JavaScript的跨preTER继续运行,而AJAX网络异步发生。这也有可能是不同的浏览器有几分不同的实现。

Under the covers, inside the browser, it could be using a separate OS thread to run the ajax call in a blocking fashion on that thread, it could be using non-blocking i/o on a separate thread, it could be using non-blocking i/o on the javascript interpreter thread (probably unlikely, but possible). It could even be using a separate process to manage networking operations with IPC to communicate between them. Which it chooses is entirely up to the browser implementation as any of those methods will allow the javascript interpreter to keep running while the ajax networking happens asynchronously. It's also possible that different browsers have somewhat different implementations.

Chrome浏览器,例如用于各个浏览器窗口,其他浏览器没有一个单独的进程。

Chrome, for example uses a separate process for each browser window which other browsers do not.

这篇关于难道JS使用非阻塞I / O在OS层面支持AJAX?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆