startChild<T> method

  1. @protected
  2. @mustCallSuper
void startChild<T>(
  1. Job<T> child
)

Adopts and starts child synchronously.

A domain that restricts child ownership overrides this method, performs its own validation, then calls super.startChild(child). It applies the synchronous admission rules of run and does not observe the child's outcome. It takes any Job, so the type that keeps a job which starts itself away from run does not guard it: such a job is refused here with an ArgumentError — one from Job(body), Job.then or Job.each.

Implementation

@protected
@mustCallSuper
void startChild<T>(Job<T> child) {
  _checkCanRun('run a child');
  _checkChild(child, 'child');
  child as JobBase<T>;
  child
    ..adoptedBy(this)
    .._observer ??= _owner._observer
    .._parent = _owner
    .._level = _owner.level + 1;
  if (_owner.pendingCancel case final pending?) {
    throw _refuseChild(child, pending);
  }
  _startAdopted(child);
}