Skip to content

Instantly share code, notes, and snippets.

@xrad
xrad / iso_ffi.dart
Created September 14, 2023 17:11
Simple Dart example to demonstrate shared memory for Isolates
import 'dart:ffi';
import 'dart:isolate';
import 'dart:io';
import 'package:ffi/ffi.dart';
void newIsolate(SendPort sendPort) {
final ptr = calloc.allocate<Int>(100);
ptr[0] = 42;
sendPort.send(ptr.address);
sleep(const Duration(seconds: 1));