-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
We might never build this, but let's have a tracking bug to point to.
https://api.dart.dev/stable/3.2.4/dart-ffi/NativeCallable/NativeCallable.listener.html enables async callbacks that return immediately upon calling and schedule the callback to be run on the Dart event loop of the right isolate. No return values can be returned.
https://api.dart.dev/stable/3.2.4/dart-ffi/NativeCallable/NativeCallable.isolateLocal.html enables sync callbacks with return values. The current thread must be the one entered in the target isolate.
If we would like to be able to run Dart code synchronously and get a return value, but we don't have access to a Dart isolate in the current thread, we could conceivably spawn a new temporary isolate.
This would incur some serious limitations:
- No access to other isolates / global state.
- No async / event loop. (Synchronous return.)
We're currently not exploring this. @liamappelbe
A way more general approach would be to have shared memory multithreading: