Skip to content

Allow sending a generic object with a function type parameter between isolates #44431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dnfield opened this issue Dec 9, 2020 · 3 comments
Closed
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-isolate

Comments

@dnfield
Copy link
Contributor

dnfield commented Dec 9, 2020

See #37294

This code fails, now with a meaningful error message:

import 'dart:isolate';

void fun() {
 print('hi from fun');
}

Future<void> main() async {
  final x = <void Function()>[fun];
  await Isolate.spawn(isolate, x);
}

void isolate(List<void Function()> foo) async {
  print('Tick: $foo');
  foo.first();
}

But this code works:

import 'dart:isolate';

void fun() {
  print('hi from fun');
}

Future<void> main() async {
  final x = <dynamic>[fun];
  await Isolate.spawn(isolate, x);
}

void isolate(List<dynamic> foo) async {
  print('Tick: $foo');
  (foo.first as void Function())();
}

It'd be nice to let the typed version work too.

@dnfield dnfield added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-isolate labels Dec 9, 2020
@dnfield
Copy link
Contributor Author

dnfield commented Dec 9, 2020

(it also works with a List<Object>)

@mkustermann
Copy link
Member

After we're done with #36097 this would probably implicitly work because we we'll share function type objects across isolates.

@mkustermann
Copy link
Member

mkustermann commented Jul 15, 2021

Closing this issue, merge into the more general #46623.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-isolate
Projects
None yet
Development

No branches or pull requests

2 participants