release method

void release(
  1. C conversation
)

Deletes conversation now, or — when an operation runs on it — stops that operation and deletes the conversation once it has ended.

Implementation

void release(C conversation) {
  final turn = _running[conversation];
  if (turn == null) {
    // Nothing of ours runs, but native may still be finishing a generation
    // whose error already ended our turn; a delete would wait for it (#364).
    cancelNative(conversation);
    deleteNative(conversation);
    return;
  }
  turn.deleteWhenEnded = true;
  cancelForClose(conversation);
}