WASM-API限制

API Limitations API限制

The browser environment and JavaScript are different from the native environments that C and C++ typically run in. These differences impose some limitations on how native APIs can be called and used. This section lists some of the more obvious limitations.

浏览器环境和JavaScript与通常运行C和C++的本机环境不同。这些差异对本机API的调用和使用方式施加了一些限制。本节列出了一些更明显的限制。

Networking 联网

Emscripten supports libc networking functions but you must limit yourself to asynchronous (non-blocking) operations. This is required because the underlying JavaScript networking functions are asynchronous.

Emscripten支持libc网络功能,但是您必须将自己限制为异步(非阻塞)操作。这是必需的,因为基础JavaScript网络功能是异步的。

File Systems 文件系统

Emscripten supports libc file system functions and C/C++ code can be written in the normal way.

Emscripten支持libc文件系统功能,并且可以按常规方式编写C / C ++代码。

Code run in a browser environment is sandboxed, and does not have direct access to the local file system. Instead, Emscripten creates a virtual file system that may be preloaded with data or linked to URLs for lazy loading. This affects when synchronous file system functions can be called and how a project is compiled. See the File System Overview for more information.

浏览器环境中运行的代码是沙盒化的,不能直接访问本地文件系统。相反,Emscripten创建了一个虚拟文件系统,该文件系统可以预加载数据或链接到URL以进行延迟加载。这会影响何时可以调用同步文件系统功能以及如何编译项目。有关更多信息,请参见文件系统概述

Application Main Loop 应用程序主循环

The browser event model uses co-operative multitasking — each event has a “turn” to run, and must then return control to the browser event loop so that other events can be processed. A common cause of HTML pages hanging is JavaScript that does not complete and return control to the browser.

浏览器事件模型使用协作式多任务处理-每个事件都有一个“转弯”运行,然后必须将控制权返回给浏览器事件循环,以便可以处理其他事件。HTML页面挂起的常见原因是JavaScript无法完成,无法将控制权返回给浏览器。

This can affect how an application using an infinite main loop is written. See Emscripten Runtime Environment for more information.

这会影响使用无限主循环编写应用程序的方式。有关更多信息,请参见Emscripten Runtime Environment

Other APIs 其他API

Support for other portable C/C++ code is fairly comprehensive.

对其他可移植C / C ++代码的支持相当全面。

原文地址:https://www.cnblogs.com/hencins/p/14119548.html