问题描述
由于服务器端部分变得更加复杂,开发人员将需要利用现有的软件。因此,Dart是否支持与本机库(特别是C库)的接口?
As the server-side part becomes more complex, developers will need to leverage the existing software. So, does Dart support interfacing with the native libraries (C libraries, in particular)?
推荐答案
您可以提供两种类型的本机扩展:异步或同步。异步扩展在单独的线程上运行本机函数,由Dart VM调度。同步扩展直接使用Dart虚拟机库的C API(Dart Embedding API),并在与Dart隔离器相同的线程上运行。通过向Dart端口发送消息,并在应答端口上接收响应来调用异步函数。
You can provide two types of native extensions: asynchronous or synchronous. An asynchronous extension runs a native function on a separate thread, scheduled by the Dart VM. A synchronous extension uses the Dart virtual machine library’s C API (the Dart Embedding API) directly and runs on the same thread as the Dart isolate. An asynchronous function is called by sending a message to a Dart port, receiving the response on a reply port.
这篇关于Dart是否支持与本机库的接口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!