-
Notifications
You must be signed in to change notification settings - Fork 37
Processes and Isolates
Dartino supports running multiple processes concurrently. Each of the processes has its own heap and they only interact with other processes through message passing. Dartino can schedule a very large amount of processes across a much smaller set of native threads. Blocking a process does not block the native thread the process is currently executing on. Dartino is currently able to run ~450,000 processes concurrently on a 32-bit machine and schedule them on a number of native threads that match the number of cores in the system.
Here's a simple example that illustrate how to spawn processes in Dartino:
main() {
for (int i = 0; i < 50000; i++) {
Process.spawn(fib, 12);
}
}
int fib(n) {
if (n <= 1) return 1;
return fib(n - 1) + fib(n - 2);
}
Isolates work at a slightly higher level than processes. The isolate APIs allow programmers to pause, resume, and kill isolates from the outside - and we expect to be able to build this on top of the lower level processes. The preview version of this is in the isolate package.