Does it make sense to do jsonDecode
with Isolate if the message passing between isolates is encoding into binary data and back again?
如果隔离之间传递的消息正在编码为二进制数据并返回,那么使用隔离进行jsonDecode有意义吗?
更多回答
优秀答案推荐
If decoding a chunk of JSON requires more than a frame of CPU, you'll get dropped frames, so it's pretty much mandatory at that point. And if you use Isolate.run
, there's minimal copying between threads, especially on the return value.
如果对JSON块进行解码需要的CPU多于一帧,则会丢弃帧,因此在这一点上几乎是强制性的。如果使用Isolate.run,则线程之间的复制最少,特别是在返回值上。
更多回答
Can you please provide some information about copying objects between isolates?
您能提供一些关于在隔离之间复制对象的信息吗?
Yes, the dart.dev website has entire sections with examples on using async and isolates.
是的,dart.dev网站有完整的章节,有关于使用异步和隔离的示例。
But there is no information about the serialization and deserialization mechanism that is used to exchange objects between isolates
但是没有关于用于在隔离之间交换对象的序列化和反序列化机制的信息
That's because Isolate.run uses Sendport/Receiveport, and for isolates in the same isolatepool, it's pretty much everything. See the SendPort documentation and the Isolate.run docs.
这是因为Isolate.run使用Sendport/Receiveport,而对于同一隔离池中的分离物,它几乎就是一切。请参阅发送端口文档和Isolate.run文档。
我是一名优秀的程序员,十分优秀!