Skip to content
This repository has been archived by the owner on Sep 15, 2022. It is now read-only.

Processes and Isolates

Michael Thomsen edited this page Jan 27, 2016 · 6 revisions

Processes

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

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. So far, we haven't implemented support for the dart:isolate library in Dartino yet.