thrd_create method

int thrd_create(
  1. thrd_t thr,
  2. int func(
    1. dynamic
    ),
  3. dynamic arg
)

Create a thread

Implementation

int thrd_create(thrd_t thr, int Function(dynamic) func, dynamic arg) {
  try {
    final exitPort = ReceivePort();
    thr._exitPort = exitPort;

    Isolate.spawn(_thrdRunner, _ThrdArg(func, arg, exitPort.sendPort)).then((iso) {
      thr.isolate = iso;
    });
    return thrd_success;
  } catch (_) {
    return thrd_nomem;
  }
}