Dart隔离访问共享对象实例

Dart隔离访问共享对象实例,dart,shared-memory,dart-isolates,Dart,Shared Memory,Dart Isolates,我目前正在使用隔离程序将查询并行发送到数据库服务器。我有一个connector对象来构建与数据库的连接,我希望在所有隔离之间共享它,因此我不必为每个隔离创建单独的连接 到目前为止,我似乎只能在隔离之间共享特殊的可序列化对象。我正在使用发送和接收端口发送消息。对于其他对象(如我的连接器对象),dart vm会产生以下错误: Illegal argument(s): Illegal argument in isolate message : (object extends NativeWrapper

我目前正在使用隔离程序将查询并行发送到数据库服务器。我有一个connector对象来构建与数据库的连接,我希望在所有隔离之间共享它,因此我不必为每个隔离创建单独的连接

到目前为止,我似乎只能在隔离之间共享特殊的可序列化对象。我正在使用发送和接收端口发送消息。对于其他对象(如我的连接器对象),dart vm会产生以下错误:

Illegal argument(s): Illegal argument in isolate message : (object extends NativeWrapper)
您知道在多个隔离之间共享通用对象实例的方法吗?还是必须为每个隔离创建单独的实例

谢谢


Pedro

来自发送端口。发送方法代码文档

   * In the special circumstances when two isolates share the same code and are
   * running in the same process (e.g. isolates created via [Isolate.spawn]), it
   * is also possible to send object instances (which would be copied in the
   * process). This is currently only supported by the dartvm.  For now, the
   * dart2js compiler only supports the restricted messages described above.
我假设作为本机对象包装的对象也不受支持。
目前唯一的方法似乎是在每个隔离中创建一个新连接

这些价值观总是有效的

   * The content of [message] can be: primitive values (null, num, bool, double,
   * String), instances of [SendPort], and lists and maps whose elements are any
   * of these. List and maps are also allowed to be cyclic.