commit method
Commits a queue created using newQueue.
The parent queue's position is updated to be the same as queue
's.
Further requests on all queues created by this transaction, including
queue
, will complete as though cancel
were called with immediate:
true
.
Throws a StateError if commit or reject have already been called, or
if there are pending requests on queue
.
Implementation
void commit(StreamQueue<T> queue) {
_assertActive();
if (!_queues.contains(queue)) {
throw new ArgumentError("Queue doesn't belong to this transaction.");
} else if (queue._requestQueue.isNotEmpty) {
throw new StateError("A queue with pending requests can't be committed.");
}
_committed = true;
// Remove all events from the parent queue that were consumed by the
// child queue.
for (var j = 0; j < queue.eventsDispatched; j++) {
_parent._eventQueue.removeFirst();
}
_done();
}