throwIfUnattended method

  1. @protected
void throwIfUnattended(
  1. String action
)

Throws StateError when called from inside this job's own JobContext.unattended work.

Four members act on the whole job, JobContext.run, JobContext.runAll, JobContext.each and JobContext.uncancellable, and unattended work is not the job: a child started there would hang on the fork's boundary with the parent waiting for it forever, and a section opened there would hold a cancellation of a body that stands in no section at all. Another job's fork is not this job's business, and the key is the job's own: forks nest, and a shared key would let the inner one pass for the outer.

Implementation

@protected
void throwIfUnattended(String action) {
  if (_inOwnFork) {
    throw StateError('$_owner cannot $action inside unattended work');
  }
}