Capability pause([Capability resumeCapability ])

Requests the isolate to pause.

When the isolate receives the pause command, it stops processing events from the event loop queue. It may still add new events to the queue in response to, e.g., timers or receive-port messages. When the isolate is resumed, it handles the already enqueued events.

The pause request is sent through the isolate's command port, which bypasses the receiving isolate's event loop. The pause takes effect when it is received, pausing the event loop as it is at that time.

If resumeCapability is provided, it is used to identity the pause, and must be used again to end the pause using resume. Otherwise a new resume capability is created and returned.

If an isolate is paused more than once using the same capability, only one resume with that capability is needed to end the pause.

If an isolate is paused using more than one capability, each pause must be individually ended before the isolate resumes.

Returns the capability that must be used to end the pause.

Source

Capability pause([Capability resumeCapability]) {
  resumeCapability ??= new Capability();
  _pause(resumeCapability);
  return resumeCapability;
}