NativeTurns<C extends Object> class

The native operation running on each conversation. Nothing deletes a conversation, and no later operation starts on it, before the one that runs has ended: a cancel only asks native to stop, and the task — and its callbacks — finish later.

Constructors

NativeTurns({required void cancelNative(C conversation), required void deleteNative(C conversation), void retryCancelNative(C conversation)?, bool serializeCancelWithNativeStart = true, Duration? cancelEndTimeout, Duration cancelRetryInterval = const Duration(milliseconds: 20)})

Properties

cancelEndTimeout → Duration?
How long a consumer waits for native to post its end after cancellation. A timeout fails the consumer but deliberately does not end the native turn or release its lock: doing either could use or delete a conversation while native still owns it.
final
cancelNative → void Function(C conversation)
Asks native to stop what runs on a conversation; returns at once.
final
cancelRetryInterval → Duration
Delay between cancellation retries while a non-serialized native send entry point is still synchronously prefilling.
final
deleteNative → void Function(C conversation)
Deletes a conversation natively.
final
hashCode → int
The hash code for this object.
no setterinherited
retryCancelNative → void Function(C conversation)
Repeats cancellation during native prefill. Production uses a quiet callback so a retained stop does not flood logs.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
serializeCancelWithNativeStart → bool
Whether cancellation must wait until a synchronous streamed-send entry point has returned. Production leaves this false so a stop can interrupt prefill; true remains available to exercise the retained-stop policy.
final

Methods

allEnded() → Future<void>
Completes when every operation registered so far has ended.
begin(C conversation, {bool nativeStartPending = false}) → NativeTurn
Registers an operation that is about to start on conversation.
cancel(C conversation) → void
Asks native to stop conversation's running operation, and marks it as asked so its cancelled end is not taken for a poisoned conversation.
cancelForClose(C conversation) → void
Stops conversation's running operation because its session or model is closing. Unlike cancel, an operation nobody had asked to stop then ends as closed under its consumer.
end(C conversation, NativeTurn turn, NativeTurnEnd how) → void
Records that turn has ended natively. Deletes the conversation first when it was released meanwhile, so whoever waits on NativeTurn.ended — the lock that orders native calls among them — runs after the delete.
nativeEntered(C conversation, NativeTurn turn) → void
Marks the boundary immediately before a spawned isolate enters the C streamed-send call. Platforms that allow concurrent cancellation issue a retained stop here, once native has work to cancel. A serialized policy keeps it retained until nativeReturned.
nativeReturned(C conversation, NativeTurn turn) → void
Marks the boundary where the spawned streamed-send call has returned. This is the first cancellation point for a serialized policy, and the final reliable boundary when an earlier notification raced or was lost.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
release(C conversation) → void
Deletes conversation now, or — when an operation runs on it — stops that operation and deletes the conversation once it has ended.
runningOn(C conversation) → NativeTurn?
The operation running on conversation, if any.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited